A key part of effective LeetCode practice is keeping a practice journal. Although LeetCode automatically tracks your solution submissions and can show you your previously submitted code, a journal gives you a more customized record of your practice sessions. You can use this to focus on the areas you need to study most.
In its most basic form, a practice journal is a list of time-stamped entries at the bottom of your model solution document. Whenever you repeat a problem, add the current date and some information about your practice session. At a minimum, write one sentence explaining the result. For example, “Solved it easily” or “Solved most of it, but got stuck on a few edge cases” or “Off by one in the binary search.” Then, if you find yourself repeating the same comments the next time around, you know where to target your practice efforts. Even a small journal entry like this will help. But with a few additional minutes after each repetition, you can get even more out of your journal. Here are two categories of notes to include.
First, you can record spreadsheet-style data. It’s best if you use an actual spreadsheet for this, so you can write formulas to calculate some fields automatically. Some ideas for what to record:
Timestamp: When you practiced.
Practice time: How long you spent solving the problem. You should observe this time decreasing as you get better at a problem.
Days between repetitions: Calculate the number of days since the last repetition. Use this with your spaced repetition system to ensure that you’re practicing at the correct intervals.
Next practice interval (days): Decide what amount to put in this field based on how well you did for the current repetition. The more easily you solved the problem, the higher the number can be.
Days remaining until next interval: Calculate this field and use it to find a problem that’s ready to practice (pick the problem with the smallest number).
Accepted on first run (yes/no): Record whether you got the problem on the first try, or whether it took a few tries. For a canonical problem that you want to master, the goal is to learn it well enough that you don’t have to rely on the compiler or the unit tests to guide you in the right direction.
Besides the spreadsheet entries, free-form journal entries are also useful. The goal of this type of section is to self-evaluate how well you know a problem and which areas are giving you trouble. Include notes about any areas where you got stuck, even if you ended up solving the problem successfully. These notes can help you polish your model solution, turning it into a solution that is exactly customized for you. You can also find problem areas by looking for bugs that show up repeatedly in your journal entries. This is more efficient than going through previous code submissions.
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.