Consider this scenario: You’re repeating a problem. You skim the problem description and remember a good approach to use. You start implementing the solution, since you know the steps for the algorithm. Then at some point in the implementation, you get stuck. Maybe there’s some language syntax that you don’t use very often. Maybe you forget how to use a library function that you need. Maybe part of the solution just doesn’t click. Whatever the reason, your practice session grinds to a halt.

Since you have solved this problem before, there’s not much point in spending more time once you’ve made a reasonable effort. What you need is a targeted hint. A general web search might help, since it could get you unstuck without revealing more than you want about this problem. If that doesn’t work, you could consult your model solution, but you might see more than just the part you’re looking for.

One way or another, you get unstuck and continue your implementation, solving the problem and getting it accepted by the online judge. But now you need to figure out how to avoid getting stuck at the same point the next time around.

The simplest approach: just continue the spaced repetition process that you’re already using. You have the problem in your repetition queue. You practiced it, got stuck on part of it, got unstuck, and completed it. Now you can adjust the repetition interval as necessary. Next time you repeat the problem, you may remember what you need and avoid getting stuck again.

But this approach is inefficient. If you use a short repetition interval, you’ll be more likely to remember the part that tripped you up, but you’ll also have to implement the part that you already know. That won’t make the best use of your practice time. But if you use a longer repetition, you might get stuck on the same part again, which means you won’t progress on this problem.

A better approach is to use spaced repetition as a tool for learning both problems and sub-problems. Rather than just repeating full problems, you can also add sub-problems to your repetition queue. (A sub-problem is any part of a problem that you get stuck on). This will allow you to select the appropriate repetition interval at a more granular level.

One note about the sub-problem approach: LeetCode tools don’t directly support sub-problems. If you want LeetCode to test your solution completely, you have to submit an entire program. But there’s a way around this. Take your model solution code and delete the part that you want to practice, leaving the part that you already know. When you’re ready to practice a sub-problem, start by pasting the partial solution into the LeetCode editor. Then implement the missing part on your own. When you’re done with your practice, adjust your repetition interval per the usual process, based on how well you did on the sub-problem.

Once you start identifying sub-problems and practicing them independently of whole problems, you’ll reduce the time required to learn each problem, since your practice will be more targeted.

*This year, I’m publishing a series of tips for effective LeetCode practice. To read the tips in order, start with A Project for 2023.*