Pattern
1. Understand the problem clearly.
- Ask clarifying questions
- Express the problem clearly in our own words, and in abstract terms
- Identify the input & output formats
- Come up with some example inputs & outputs
- Try to find edge cases
2. First solution
- Explain it in simple words
- Solve one of the input step-by-step with the first solution
- Treat edge cases
- Time & Space Complexity analysis
- If you know it’s not the optimal solution, say that
- Look where it is not optimal: time-consuming steps, space-consuming structures
- Iterate what you find to a new solution
3. Optimal solution
- Explain it in simple words
- Solve one of the input step-by-step with the first solution
- State why is better than the first one