Red-Green-Code

Deliberate practice techniques for software developers

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

LeetCode Tip 9: Spaced Repetition

By Duncan Smith Mar 8 0

LeetCode 2023

One way to use LeetCode is to solve as many problems as possible. The argument for that approach is that the more problems you solve, the more experience you get, which will make it more likely that you’ll be able to solve the problems you encounter in an interview. There is some merit to this argument. If you never practice solving binary tree problems, it’s unlikely that you’ll be successful if an interviewer asks you to reverse a binary tree. However, the opposite may not be true. If you practice 100 binary tree problems, you might still not solve the particular binary tree problem you encounter in an interview.

The purpose of model problems and model solutions is to improve the quality of your practice, independent of the number of problems you solve. You should add a problem to your list of model problems because you think it’s the best problem you know of to learn a particular skill. The model solution you create for that problem explains everything important about that problem, including parts you may not notice if you just solve it once and move on.

But writing a model solution doesn’t mean you’re done with a problem. It’s good experience to select a model problem, solve it on your own, study other people’s solutions, and write your model solution. You’ll know a lot more about that problem than you did when you started, and you’ll know better how to solve related problems. But even after doing this work, you’ll be far from an expert in that problem. If you doubt this, find a LeetCode Medium problem and follow the preceding steps to write a model solution for it. Then wait 30 days and try to solve it under timed interview conditions. My guess is that you’ll find it challenging, even though you’re re-solving a problem that you have studied in depth.

To effectively use model problems and solutions, you need another tool, spaced repetition. When you first study a LeetCode Medium problem, there are a lot of details to keep track of. You have to understand what the problem is asking, the algorithms and data structures you need to use to compute the result, and the implementation details for your chosen language. It can be difficult to keep everything straight, so you may not have the spare mental capacity to learn the more general lessons the problem offers. But if you repeat the problem a second time, some of it will be familiar. You won’t have to think as much about some parts of the problem-solving process. You’ll be able to focus on details that you may have missed the first time. With each repetition, some aspect of the problem will become easier, until you reach a level of mastery where you can solve the problem from start to finish with minimal effort.

That’s the repetition part. The spaced part is the time between repetitions. If you solve the same LeetCode Medium problem every day, it will get quite easy after a few days. But if you stop practicing it for 30 days and pick it up again, you might discover that it has somehow become difficult again. To avoid this problem, you need to schedule your repetitions effectively. In the next tip, we’ll look at how to design a spaced repetition plan that makes the most of each practice session.

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:

  • 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

  • LeetCode Tip 11: How To Use Spaced Repetition (Part 1) March 22, 2023
  • LeetCode Tip 10: Planning a Spaced Repetition Schedule March 15, 2023
  • Book Review – Algorithmic Thinking: A Problem-Based Introduction, Second Edition March 9, 2023
  • LeetCode Tip 9: Spaced Repetition March 8, 2023
  • LeetCode Tip 8: Anatomy of a Model Solution March 1, 2023
  • LeetCode Tip 7: How to Write a Model Solution February 22, 2023
  • LeetCode Tip 6: Model Solutions February 15, 2023
  • LeetCode Tip 5: Choosing a Model Problem February 8, 2023
  • LeetCode Tip 4: Model Problems February 1, 2023
  • LeetCode Tip 3: A Goal for LeetCode Practice January 25, 2023
Red-Green-Code
  • Home
  • About
  • Contact
  • Project 462
  • CP FAQ
  • Newsletter
Copyright © 2023 Duncan Smith