I've been practicing algorithm problems and noticed that when I get stuck, I often read a solution, understand it briefly, and then move on. A few days later, I may remember the general shape of the answer without understanding why it works.
The Valid Parentheses problem exposed this habit. I knew a stack was involved and could reproduce the code after seeing it, but I struggled to explain why a stack fits, how an empty stack should be handled, and why the worst-case space complexity is O(n).
I'm trying to slow down by writing my own explanation before checking another walkthrough or using an AI assistant for hints and alternative explanations. I also ask myself what the main pattern is, why the data structure fits, which edge case defeats a naive approach, and how to justify the complexity.
This takes longer, but the ideas seem to stick better. What review process helps you develop real problem-solving skills instead of memorizing solutions?
3 Answers
Try to solve the problem and outline the approach before writing any code. Once the reasoning is clear, the code should mostly be an implementation of that plan. If your explanation changes while coding, update it—that usually reveals which part of the idea you hadn’t fully worked out yet.
Give yourself a serious attempt before looking anything up. Re-read the requirements, list the information you have, question your assumptions, consider a brute-force approach, and then look for what would make it more efficient. Taking a break and returning later can also help. Reading someone else’s solution is useful as a last resort, but it doesn’t replace the mental effort of solving the problem yourself.
Don’t treat the problem set as a collection of answers to memorize. Treat it like practice for your reasoning skills. After solving one, revisit it later, rewrite the solution from memory, and explain the pattern, edge cases, and complexity without looking at the code.

A hint is a good middle ground. It can point you toward a pattern without removing the need to study the algorithm and implement it yourself.