How to Study Programming
Learning strategies that actually stick: active recall, spaced repetition, deliberate practice, and a repeatable framework for attacking problems you have never seen.
beginner30 min#learning#spaced-repetition#active-recall#problem-solving
Why it matters
Most people who struggle with programming are not short on talent. They are using study habits that feel productive but barely work: rereading notes, watching tutorials at 1.5x speed, copying a solution and nodding along. Everything else in this site, from arrays to system design, is only useful if it is still in your head six months from now. A few well-studied techniques roughly double how much you retain for the same hours, and a simple problem-solving routine turns a blank editor from a source of panic into a checklist.
Intuition
Memory behaves like a muscle that rewards effort, not exposure. Two ideas explain most of what works.
Retrieval beats review. Trying to pull an answer out of your head, even when you fail, strengthens the memory far more than looking at the answer again. Rereading creates a feeling of familiarity ("yes, I know this"), and familiarity is not the same as being able to produce the idea on a whiteboard.
Forgetting is predictable. Without review, a memory fades quickly at first and then slowly. Each successful recall flattens the curve, so the next review can wait longer. That is the whole basis of spaced repetition: review each item just before you would forget it, and the gaps grow from a day to a week to a month.
recall
100% |*
| * *
| * review / * review
| * | / * | *
| * v / * v / *
| * ___/ * ______ / *
+------------------------------------> time
day 0 day 2 day 9 day 30
Each review resets the curve, and each reset decays more slowly than the last.
How it works
A practical study loop has four parts.
- Learn actively. After reading a section, close it and write down what you remember: the idea, an example, the complexity. Then type the code from memory before checking.
- Space your reviews. Turn each concept into a small card (a question on one side, an answer on the other). Review cards on a growing schedule. The Leitner system is the simplest version: boxes with intervals such as 1, 2, 4, 8, 16 days. A correct answer moves a card up a box; a wrong one sends it back to box one.
- Practice deliberately. Work at the edge of your ability. If every problem is easy you are not learning; if none are solvable you are just frustrated. Aim for problems you solve about 60 to 70 percent of the time with effort. After each one, write down what idea you were missing.
- Mix topics. Interleave problem types rather than doing ten sliding-window problems in a row. Mixing forces you to decide which technique applies, which is exactly the skill interviews test.
A framework for any problem
When you meet a new problem, resist typing. Walk through these steps in order.
- Restate it. Say the input, output, and constraints in your own words. How large can
nbe? Can values repeat? Can the input be empty? - Work a tiny example by hand. Pick a case with three or four items and solve it on paper. Notice what you actually did.
- Brute force first. State the obvious slow solution and its cost. This is a working baseline and often hints at the optimization.
- Find the bottleneck. What repeated work can a hash table, sorting, a pointer, or a cache remove?
- Code it, then test it. Run your tiny example plus edge cases (empty, one item, duplicates, the largest size).
- Review. Say the time and space cost, then note the pattern so you can recognize it next time.
| Operation | Time | Notes |
|---|---|---|
| Rereading notes | Low retention | Feels easy, weak memory |
| Active recall (self-quizzing) | High retention | Harder now, remembered later |
| Spaced repetition | Highest per hour | Reviews cost minutes per day |
| Cramming | Short-lived | Gone within days |
Code: a tiny spaced-repetition scheduler
This is the Leitner system in a few lines. Each card sits in a box; the box decides how many days to wait before the next review. We replay a short history for one card.
INTERVALS = [1, 2, 4, 8, 16] # days to wait per Leitner box
class Card:
def __init__(self, name):
self.name = name
self.box = 0
self.due = 0
def review(card, correct, today):
if correct:
card.box = min(card.box + 1, len(INTERVALS) - 1)
else:
card.box = 0
card.due = today + INTERVALS[card.box]
def due_cards(cards, today):
return [c.name for c in cards if c.due <= today]
card = Card("two pointers")
history = [(0, True), (1, True), (3, True), (7, False), (8, True)]
for day, ok in history:
review(card, ok, day)
print(f"day {day}: {'right' if ok else 'wrong'} -> box {card.box}, next review day {card.due}")
import json
print(json.dumps(due_cards([card], 9)), json.dumps(due_cards([card], 10)))const INTERVALS = [1, 2, 4, 8, 16]; // days to wait per Leitner box
class Card {
constructor(name) {
this.name = name;
this.box = 0;
this.due = 0;
}
}
function review(card, correct, today) {
card.box = correct ? Math.min(card.box + 1, INTERVALS.length - 1) : 0;
card.due = today + INTERVALS[card.box];
}
function dueCards(cards, today) {
return cards.filter((c) => c.due <= today).map((c) => c.name);
}
const card = new Card("two pointers");
const history = [[0, true], [1, true], [3, true], [7, false], [8, true]];
for (const [day, ok] of history) {
review(card, ok, day);
console.log(`day ${day}: ${ok ? "right" : "wrong"} -> box ${card.box}, next review day ${card.due}`);
}
console.log(JSON.stringify(dueCards([card], 9)), JSON.stringify(dueCards([card], 10)));Both versions print:
day 0: right -> box 1, next review day 2
day 1: right -> box 2, next review day 5
day 3: right -> box 3, next review day 11
day 7: wrong -> box 0, next review day 8
day 8: right -> box 1, next review day 10
[] ["two pointers"]
The miss on day 7 drops the card back to box zero, so it returns the next day. Real tools such as Anki use finer-grained formulas, but the shape is the same.
Common pitfalls
- Tutorial hell: watching solutions without attempting the problem first. Struggle for at least 15 to 20 minutes before looking at a hint, then redo the problem from scratch the next day.
- Memorizing solutions instead of patterns: you will fail on the first variation. After solving, ask "what is the general idea, and what would change it?"
- Skipping the schedule: spaced repetition only works if you actually review. A tiny daily habit beats an ambitious plan you abandon.
- Studying only what feels good: we naturally practice our strengths. Track topics you avoid and schedule them on purpose.
- Never practicing without your IDE's help turned off: autocomplete hides gaps. Practice some problems in a plain editor, as you will in an interview.
Practice
Design your card set easy
Hint
One fact per card, phrased as a question you could answer from memory.
Show solution
Pick the arrays lesson and write five cards, for example: "Why is a[i] O(1)?" (address arithmetic), "What makes append amortized O(1)?" (geometric resizing). Good cards are short, specific, and have one correct answer. If you cannot write the answer from memory, that card is already telling you what to restudy.
Extend the scheduler with a lapse penalty medium
Hint
Instead of always resetting to box 0, what if a miss only moved the card back two boxes?
Show solution
Change the wrong branch to card.box = max(card.box - 2, 0). Cards you mostly know return sooner but do not lose all progress. Compare both policies by replaying the same history: the gentler rule keeps well-known cards on longer intervals, at the cost of occasionally seeing a shaky card too late. Real systems tune this trade-off per card.
Apply the framework to Two Sum medium
Hint
Write the brute force first and count how many pairs it checks.
Show solution
Restate: given numbers and a target, find two indexes whose values sum to it. By hand with [2, 7, 11, 15] and target 9, you notice that for each number you need to know whether target - x has been seen. Brute force checks every pair, O(n^2). The bottleneck is the repeated search; a hash map from value to index makes each lookup O(1), so one pass gives O(n) time and O(n) space. Test with duplicates ([3, 3], target 6) and with no answer.
Compute a review load hard
Hint
A card in box k is reviewed once every INTERVALS[k] days.
Show solution
If you add 5 new cards every day and every card is always answered correctly, how many reviews per day does the steady state need once cards reach the top box (16 days)? Each card is reviewed once per 16 days, and there are 5 new cards per day, so in steady state you hold about 5 * 16 = 80 cards in the last box, giving 5 reviews a day from that box. Add cards still climbing (about 5 per day from each lower box, divided by interval) and the total is only a handful per day. This is why spaced repetition scales: review load grows slowly while knowledge grows steadily.
Interview questions
- How do you approach a problem you have not seen before? Restate it, try a small example by hand, state a brute force solution with its cost, then optimize the bottleneck.
- What do you do when you are stuck in an interview? Say what you have tried, return to a smaller example, ask a clarifying question, or offer the brute force and improve it.
- How do you keep skills fresh across many topics? A small deck of cards with spaced reviews plus periodic mixed practice, rather than one topic at a time.
- Tell me about something hard you learned recently. A behavioral variant; the best answers describe a concrete method (practice loop, feedback, reflection), not just effort.
Interviewers look for: a structured, spoken thought process, willingness to start with a simple solution, and honest reflection on what you would do differently.
Quick check
Which study habit gives the most long-term retention for the time spent?
Finished this lesson?
Further resources
- Spaced repetition (Wikipedia) (article)
- Leitner system (Wikipedia) (article)
- Learning How to Learn (Coursera) (course)