Solving LeetCode problems is a specialized type of programming. Just as some programmers like to work on low-level code for embedded systems, and others are experts in web applications, programmers may choose to learn interview programming using LeetCode.
But while programmers use their real-world specialty every workday, they might go years between job interviews. So if you’re going to invest more than a little time in LeetCode practice, it’s worth thinking about how best to retain your hard-won interviewing skills during the time between interviews.
To learn more about the ideas in this tip, see No, You Haven’t Forgotten Everything by Scott Young.
Here’s the canonical LeetCode interview preparation process:
- Step 1: Decide that it’s time to look for a job.
- Step 2: Grind on LeetCode for a few weeks/months.
- Step 3: Interview with multiple companies. Get multiple offers. Make them fight each other.
- Step 4: Profit
During the time that you’re preparing for interviews, there’s an immediate benefit to carving out time in your schedule for LeetCode practice. But once you accept an offer, you have other priorities. Rather than proving your value in an interview, you’ll be proving your value by ramping up on your new job. So how do you avoid losing all your LeetCode skills while you’re busy doing real-world programming?
To answer that question, it helps to understand why we forget things. The obvious answer is disuse. The more time that goes by since you last implemented Dijkstra’s Algorithm, the more likely it is that you’ll forget some details.
But there’s also a less obvious explanation for forgetting: interference. According to the theory of interference, we never truly forget anything. Some memories are just more difficult to recall. As an analogy, imagine that there’s a web page that has some information you’re looking for, but you’re having trouble finding the search query that returns it.
Interference is problematic because it prevents you from remembering something that you need. But it’s also useful because it focuses your brain on the memories that are most relevant to your current needs. For example, if you’re working on a real-world programming task, you might not want to remember every LeetCode pattern you have learned. But in an interview, you would like to have access to those memories.
To recall the right memories at the right time, you can take advantage of the brain’s system for bringing less used memories back into active use. As explained in LeetCode Tip 43: Find the Zone of Optimal Improvement, the brain maintains a retrieval strength for each memory, which it increases when a memory is useful but difficult to retrieve.
This system is the key to maintaining your LeetCode investment. If you learn a topic thoroughly the first time around (e.g., by using the process outlined in these tips), you can be confident that it will be stored in your long-term memory. So when it’s time to prepare for another interview, you can wake up these hard-to-recall memories, rather than learning topics from scratch. Then, when it’s time to go back to full-time job mode, you can let those memories go dormant again.
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.