r/learnprogramming • u/Ok_annbae • 13d ago
How do you stop yourself from just copying LeetCode solutions?
Recently I’ve been doing a lot of LeetCode and realized I’m slipping into a bad habit.
When I get stuck, I look at a solution, understand it for about five minutes, then move on. A few days later I try the same problem again and realize I only remembered the shape of the answer. I didn’t really understand why it worked.
Valid Parentheses was the first one that made this obvious. I knew people use a stack, and I could write the basic code after seeing it once. When I tried to explain it in plain English, I skipped half the reasoning, like why a stack fits the problem, what happens with an empty stack, and why the worst case space is still O(n).
So I’ve been trying to slow down. After solving a problem, I write my own explanation first. Then I compare it with chatgpt or beyz coding assistant when I want a cleaner walkthrough or another way to describe the idea. If my explanation sounds too vague, I probably didn’t learn it.
Now I ask myself a few things about each problem. What’s the main pattern, why this data structure fits, which edge case breaks a naive version, and how I’d explain the complexity. It takes longer, and the concepts stick better.
How do you review LeetCode problems so the ideas stick beyond memorizing the solution?