How long should I struggle with a DSA problem before checking the solution?

August 6, 2026 4 answers
Asked by MellowPine42
I'm practicing data structures and algorithms, especially sliding-window problems, but I sometimes spend two or three hours trying to find a solution. How can I tell whether I'm making useful progress or just going in circles? When should I use a hint or read the solution, and how can I make sure I actually learn from it instead of simply copying the answer?

Answers

QuietMaple63
Looking at a solution can be part of learning, but donโ€™t stop at reading it. Study the key idea, identify the clue that reveals the pattern, close the explanation, and recreate the algorithm yourself. Itโ€™s also useful to revisit the problem later and solve it again without assistance. Over time, repeated exposure to patterns such as sliding windows will make similar problems much faster.
Reply to this answer
BriskOrbit29
If you have a deadline, look up the solution sooner so you donโ€™t lose the entire study session. For pure practice, spend some time exploring first, then use the smallest amount of help neededโ€”a hint, a diagram, or the core idea. Immediately copying a complete solution may produce working code, but it usually teaches less than reconstructing it yourself.
Reply to this answer
CrispHarbor7
A practical limit is around 20โ€“30 minutes if youโ€™re completely stuck, or up to 30โ€“45 minutes if youโ€™re still making meaningful progress. Start with a hint or the general pattern rather than immediately reading the full solution. Then put it away and implement the approach yourself from memory. The point is to learn how to recognize patterns, not to prove that you can independently invent every known algorithm.
Reply to this answer
LunarCactus18
Pay attention to whether youโ€™re actually eliminating possibilities, testing ideas, or improving your understanding. If youโ€™re just staring at the same code, repeating failed attempts, or feeling burned out, take a break and come back with fresh eyes. If you still have no direction after that, checking the solution is completely reasonableโ€”just focus on understanding the logic and how you could recognize the same approach in a future problem.

MellowPine42: That makes sense. Iโ€™ll try to distinguish between slow progress and simply going in circles before looking for help.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions