Red-Green-Code

Deliberate practice techniques for software developers

  • Home
  • About
  • Contact
  • Project 462
  • CP FAQ
  • Newsletter

LeetCode Tip 12: How To Use Spaced Repetition (Part 2)

By Duncan Smith Mar 29 0

LeetCode 2023

As you use a spaced repetition process for LeetCode practice, there are more things to keep in mind than just reproducing the solution correctly. Here are more tips to get the most out of the process.

Make sure you’re practicing the right problem

Before you start spaced repetition practice, you need to choose a model problem and write a model solution. But it may take several repetitions to figure out whether the problem you selected is the best problem for your current level of mastery of a topic. If you write a detailed solution for a problem and refine it over several repetitions, but you still have trouble reproducing the solution, it may be best to leave that problem for later. Maybe the problem combines multiple techniques in a tricky way, or builds on fundamentals that you haven’t yet mastered. It’s fine to switch to another problem in the same area, and come back to the original problem later. Spaced repetition works well to strengthen your understanding of a topic, but it’s not designed for learning a topic from scratch.

Understand the solution rather than memorizing it

Another advantage of spaced repetition is that it tells you when you’re trying to memorize a solution rather than learning it. For short practice intervals (up to a few days), you won’t know for sure whether you really know a solution. Although you may succeed in reproducing it, this could be because you remember it from the previous interval. But as you increase the interval length, it becomes increasingly difficult to remember a solution unless you understand it (unless you’re using sophisticated memorization techniques, which are better for card tricks than programming). So once you get to a 15- or 30-day interval, you can be confident that you know how the solution works, not just how to reproduce the code.

Develop building blocks to use for other problems

Repeating a problem that you have already solved uses skills that differ from the ones required to solve an unknown problem. But the first type of practice can help with the second. For example, if you encounter an unknown problem that seems like it may need a binary search solution, that knowledge won’t help unless you can implement binary search. So as you write your model solutions, remember that you’ll need to use these solutions for other problems in the future. When possible, write them in a way that isn’t too specific to the problem at hand. Some competitive programmers use this approach by assembling a code notebook to use as a guide for implementing tricky algorithms. But interviewers generally don’t allow this type of notebook, since they want to see you write code yourself. So for interviews, it’s best to keep the notebook in your head.

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.

Categories: LeetCode

Prev
Next

Stay in the Know

I'm trying out the latest learning techniques on software development concepts, and writing about what works best. Sound interesting? Subscribe to my free newsletter to keep up to date. Learn More
Unsubscribing is easy, and I'll keep your email address private.

Getting Started

Are you new here? Check out my review posts for a tour of the archives:

  • 2023 in Review: 50 LeetCode Tips
  • 2022 in Review: Content Bots
  • 2021 in Review: Thoughts on Solving Programming Puzzles
  • Lessons from the 2020 LeetCode Monthly Challenges
  • 2019 in Review
  • Competitive Programming Frequently Asked Questions: 2018 In Review
  • What I Learned Working On Time Tortoise in 2017
  • 2016 in Review
  • 2015 in Review
  • 2015 Summer Review

Archives

Recent Posts

  • Do Coding Bots Mean the End of Coding Interviews? December 31, 2024
  • Another Project for 2024 May 8, 2024
  • Dynamic Programming Wrap-Up May 1, 2024
  • LeetCode 91: Decode Ways April 24, 2024
  • LeetCode 70: Climbing Stairs April 17, 2024
  • LeetCode 221: Maximal Square April 10, 2024
  • Using Dynamic Programming for Maximum Product Subarray April 3, 2024
  • LeetCode 62: Unique Paths March 27, 2024
  • LeetCode 416: Partition Equal Subset Sum March 20, 2024
  • LeetCode 1143: Longest Common Subsequence March 13, 2024
Red-Green-Code
  • Home
  • About
  • Contact
  • Project 462
  • CP FAQ
  • Newsletter
Copyright © 2025 Duncan Smith