Red-Green-Code

Deliberate practice techniques for software developers

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

LeetCode Tip 11: How To Use Spaced Repetition (Part 1)

By Duncan Smith Mar 22 0

LeetCode 2023

Spaced repetition might seem like a memorization process. In its simplest form, you use spaced repetition by simply reading a prompt and responding with the correct answer. In the LeetCode context, the prompt is the LeetCode problem description, and the answer is an accepted solution. If you solve the same model problem multiple times, you get better at solving that problem and similar problems.

But LeetCode problems and solutions are longer and more complex than standard spaced repetition content, so it doesn’t work to approach them the same way. Here are a few things you can try to do as you use the process.

Improve your model solution

The goal when writing a model solution is to explain the best way to solve the problem, using your own experience and what you have learned from other people’s solutions. But no matter how careful you are to include every relevant detail, you will always find out more about the problem as you practice it. Taking a break from a problem to do other things (including solving other problems) gives your subconscious time to work on it. When you come back to it, you’ll notice additional details, and you’ll probably find that some parts are more difficult than you thought they were when you wrote the solution. Use this insight to improve your model solution. If you had trouble with part of the problem during a repetition, update the solution to explain that part more clearly.

Adjust the problem difficulty

Learning through problem-solving is most efficient when you practice problems that are just hard enough. It’s not useful if they’re so easy that you can solve them in your sleep. And if they’re so hard that you can’t make progress on them, you won’t learn anything either. But it’s not always possible to find problems at exactly the right difficulty level, unless you have an instructor to write problems specifically for you. Spaced repetition can help in this situation. A problem that you have studied previously is easier if you try it again soon after you have solved it, and harder if you wait longer. So you can adjust the difficulty of a problem by adjusting the repetition interval. If it’s too easy, wait longer to solve it again. If it’s too hard, reduce the interval or improve the solution to better explain the hard parts.

Narrow down a problem area

As you practice a problem using spaced repetition, you may encounter the following situation: After practicing a problem a few times at increasing intervals, you remember most of the solution but forget part of it. This is fine. It’s the spaced repetition process working, making you aware of a specific part of the problem that you haven’t completely learned. When this happens, you could reduce the practice interval, which is what the spaced repetition process says to do when you have trouble with a repetition. But if you have already practiced the problem several times at longer intervals, reducing the practice interval may not be the best option. Instead, keep the current interval, but write a detailed analysis of the difficult area in your practice notebook. The reason not to go back to a shorter interval is that while that will help you solve the problem successfully, it promotes a memorization approach. Once you reach an interval of a week or two, the goal is to rely on understanding the solution rather than remembering it. If you remember anything, it will be the general solution structure rather than lines of code. Once you get to this level of understanding of a problem, it’s best to keep using it, even if it means you have trouble solving it. If things still aren’t working out after a few tries with the same interval, it’s fine to reduce the duration. But try the other approach first.

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