How do you build a practice routine for data structures that compounds over time?
You keep a log of what you have practised, and you use it to decide what to practise next. The routine compounds because each session is chosen by the last one.
from collections import Counter
attempts = ["two sum", "two sum", "kadane", "valid parentheses", "two sum", "kadane"]
def review_queue(log):
seen = Counter(log)
# The questions you have done least go to the front.
return [name for name, times in seen.most_common()][::-1]
So what makes a routine compound? Four things.
the part of the routine why it helps
---------------------------- -----------------------------------------
a fixed amount every day the habit is what matters, not the
length of the session
a short review of old work you stop making the same mistake
twice
new questions every session the material stays fresh
a record of what you did the next session is chosen by it
And there is one thing that makes the difference between a routine that works and one that does not. The review of old work. It feels like a waste of time because you already know the answers, but it is where the learning happens.
the part of the session the time it takes
---------------------------- -------------------
two new questions 60 percent
one question you got wrong 30 percent
one question from long ago 10 percent
And there is a detail worth knowing about the spaced repetition part. The questions you got wrong come back sooner than the ones you solved first time. And the ones you solved first time come back after longer and longer gaps. So the schedule gets longer for the easy questions and stays short for the hard ones.
And the last point about compounding is the one that people miss. The value is not in the questions you solve. It is in the mistakes you stop repeating. So the record that matters most is not the list of what you solved, it is the list of what you got wrong.
So the rule to remember is this. Keep the log of your mistakes, and let it choose your next session.
The last question in this topic is about keeping the preparation balanced.