Using a practice journal for your LeetCode practice helps you learn as much as you can from a single problem. This requires a different mindset than using a problem list from Tech Interview Handbook, NeetCode, or the Daily LeetCoding Challenge. When you use a problem list, your goal is to get a variety of experience from a set of problems. A practice journal, on the other hand, helps you learn one problem as thoroughly as possible.
You can learn a lot by working on one problem through multiple repetitions. Every LeetCode problem covers one or more common concepts. By repeatedly solving the same problem, you can focus on the concept rather than having to figure out a new scenario, as you would if you kept picking new problems. For example, there’s a binary search problem that asks you to add events to a calendar. The first time you solve that problem, you need to spend time understanding the scenario. But the scenarios in LeetCode problems are less complex than the associated algorithm. So it may take only one or two repetitions to master the scenario, at which point you can focus on the algorithm.
Although the scenario may be simple, it is still a useful part of the problem. Recalling the steps of an algorithm is difficult in the abstract. Studying algorithms with an associated a scenario gives your brain something to latch onto. When you encounter a similar problem, rather than having to recall “binary search,” you can instead recall “how to add an event to a calendar without double booking.” As you practice more model solutions for an algorithm, you’ll learn multiple scenarios that help you approach the algorithm from different angles.
Practicing the same binary search problems multiple times doesn’t directly teach you to solve new binary search problems. But it’s a prerequisite for that skill. It helps you master binary search and several associated scenarios. When you encounter a new problem that tickles your binary search sense, you can focus on the specifics of that new problem, confident that you have mastered the implementation.
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.