Skip to content

Paced.Guides

Spaced repetition for LeetCode and DSA: a review plan for coding interviews

Published · Updated

Sources checked on by , founder of Paced.

In short. Solving a problem once tells you that you could solve it that evening. Interviews ask whether you can recognise and solve a problem of that kind weeks later, under time. The answer is spaced repetition: LeetCode patterns, not single problems. Treat each pattern — two pointers, sliding window, topological sort — as a topic: learn it once, then re-solve one fresh problem of that pattern on growing gaps, without looking at a solution. 14 patterns at two a week, 2 h each the first time, fit in 8 h 24 a week at the peak; the same 14 at three a week push the peak to 11 h 45 in weeks 3 and 4, over the 11 h that evenings and weekends hold.

Why problems fade, and patterns last longer

Two findings from learning research apply directly to interview prep:

  • Spread the practice. College students who split ten problems of one kind across two sessions a week apart did much better four weeks later than students who did all ten in one sitting; extra problems in the same sitting did nothing (Rohrer & Taylor, 2006). Grinding twenty sliding-window problems in one weekend is the second group.
  • Mix the kinds. When practice problems of different kinds were interleaved, students learned to pick the right method and did better on a later test than students who practised one kind at a time (Taylor & Rohrer, 2010). An interview never tells you which chapter the problem is from.

And the review has to be retrieval: practising recall beat restudying on later tests (Karpicke & Roediger, 2008; Roediger & Karpicke, 2006). Reading your old solution is restudy. What a good recall session looks like is in active recall and spaced repetition.

The unit of review: a pattern, not a problem

If every solved problem becomes something to review, the list grows by several a day and the reviews swamp the new material. Review patterns instead: each one is a topic, and each review is one new problem of that pattern. A working list of 14:

  1. Arrays and hashing
  2. Two pointers
  3. Sliding window
  4. Stack and monotonic stack
  5. Binary search (including on the answer)
  6. Linked lists
  7. Trees: depth-first and breadth-first
  8. Heaps and top-k
  9. Backtracking
  10. Graphs: BFS and DFS
  11. Topological sort
  12. Union-find
  13. Dynamic programming, one dimension
  14. Dynamic programming, two dimensions

The order matters less than finishing each pattern's first study properly: the idea, the template, three problems solved with help if needed.

What a review looks like

Paced's Standard pace places the reviews of a pattern at D+1, D+3, D+7, D+15, D+30, D+60 after the first study. For a 2 h first study, the default review lengths are 36 min, 31 min, 26 min, 22 min, 17 min, 12 min. In that time:

  1. Pick a problem of that pattern you have not solved before (or not in the last month).
  2. Set a timer. Say or write the approach before coding: which pattern, why, what the invariant is.
  3. Code it without looking anything up.
  4. Then check: complexity, edge cases, a reference solution if you got stuck.
  5. If you could not start, the pattern needs a second first study, not a longer review.

A 10-week plan around a full-time job or classes

14 patterns, two new ones a week for 7 weeks, 2 h per first study, Standard pace, any day of the week a study day. Budget: one hour on five weeknights and three hours on Saturday and Sunday, 11 h a week. Our calculation:

14 patterns, Standard pace — against 11 h a week
WeekFirst studiesReviewsTotalFits 11 h?
14 h2 h 146 h 14yes
24 h3 h 067 h 06yes
34 h3 h 507 h 50yes
44 h3 h 507 h 50yes
54 h4 h 248 h 24yes
64 h4 h 248 h 24yes
74 h4 h 248 h 24yes
802 h 102 h 10yes
901 h 301 h 30yes
10058 min58 minyes
The same plan, hours per week. Bars over the line go past 11 h a week; our calculation with Paced's default review lengths.

What it costs per week

Reviews grow for the first weeks and then hold at about 4 h 24 a week while new patterns keep coming. From week 8 there is nothing new: reviews drop to 2 h 10, then 1 h 30, then 58 min, which leaves the weekends for timed mixed sets and mock interviews.

What happens if you go faster

Three new patterns a week (the same 14 in 5 weeks) on the same budget, our calculation:

The same 14 patterns, three a week — against 11 h a week
WeekFirst studiesTotalFits 11 h?
16 h8 h 50yes
26 h10 h 39yes
36 h11 h 45no, over by 45 min
46 h11 h 45no, over by 45 min
54 h10 hyes
602 h 49yes
701 h 35yes
8051 minyes

The plan breaks in a later week, not the first: from week 3 the reviews of the first patterns arrive on top of the new ones and the week goes over 11 h. If your interview date is close, cut the list rather than the reviews.

Mix the patterns in the last weeks

From week 8, replace pattern-by-pattern reviews with mixed sets: three problems from three different patterns, without the pattern named. That is the interleaving effect in practice, and it is what the interview tests. To lay the weeks out around your own evenings, use the study schedule maker; for one pattern's dates, the spaced repetition calculator.

Using a problem site with this plan

Any problem site or public list works as a source of fresh problems for each pattern: tag the problems by pattern, keep a short log of which ones you have done, and draw the next review's problem from the untouched ones.

LeetCode is a trademark of its owner. Paced is not affiliated with LeetCode.

Paced plans each pattern's first study and reviews inside the evenings and weekends you actually have, moves what you missed, and warns you before a week will not fit. The web plan is free for up to 8 active topics, 7 days ahead, with no card; the iPhone and iPad app needs Plus. Try it without an account.

Questions

Does spaced repetition work for DSA and LeetCode?

Spacing and mixing problem practice both improved later test performance in studies of problem solving (Rohrer & Taylor, 2006; Taylor & Rohrer, 2010). Apply it to patterns, and make every review a fresh problem solved without help.

Should I re-solve the same LeetCode problem?

Not as your main review: you remember the answer, not the method. Re-solve a different problem of the same pattern, and repeat an old problem only after a long gap.

How many problems a day for coding interviews?

Count hours, not problems. In our example, two new patterns a week plus their reviews take 6 h 14 to 8 h 24 a week; three new patterns a week no longer fit 11 h a week from week 3, peaking at 11 h 45 in weeks 3 and 4.

What intervals should I use for coding problems?

Growing gaps work: Paced's Standard pace (D+1, D+3, D+7, D+15, D+30, D+60) for an interview two months away; a tighter one such as Intensive (D+1, D+2, D+4, D+7, D+12…) if it is a few weeks away. The best gap shrinks as the test gets closer (Cepeda et al., 2008).

Can I use flashcards for algorithms?

Cards help for facts such as complexities. Patterns are skills: the review that tests them is writing code for a new problem, which a card cannot hold.

Sources

  1. Rohrer, D., & Taylor, K. (2006). The effects of overlearning and distributed practise on the retention of mathematics knowledge. Applied Cognitive Psychology, 20(9), 1209–1224. 216 students solving one kind of maths problem: splitting ten problems across two sessions a week apart did nothing at one week but helped a lot at four weeks; extra problems in one sitting (overlearning) did nothing.
  2. Taylor, K., & Rohrer, D. (2010). The effects of interleaved practice. Applied Cognitive Psychology, 24(6), 837–848. Mixing practice problems of different kinds taught students to pick the right method, and improved a later test.
  3. Karpicke, J. D., & Roediger, H. L. (2008). The critical importance of retrieval for learning. Science, 319(5865), 966–968. Repeated testing had a large effect on delayed recall; repeated studying after learning had none.
  4. Cepeda, N. J., Vul, E., Rohrer, D., Wixted, J. T., & Pashler, H. (2008). Spacing effects in learning: A temporal ridgeline of optimal retention. Psychological Science, 19(11), 1095–1102. More than 1,350 learners, review gaps up to 3.5 months, final tests up to a year later.
  5. Roediger, H. L., & Karpicke, J. D. (2006). Test-enhanced learning: Taking memory tests improves long-term retention. Psychological Science, 17(3), 249–255. On tests two days and one week later, practising recall beat restudying the same text.