Professor Turing

Study guides

How to prepare for a coding interview

Last updated: 2026-11-24

To prepare for a coding interview, learn a handful of solution patterns before you grind problems, solve each problem out loud, redo it from a blank page about three days later, and write down each mistake in an error log so you can test yourself on it. The studies we read were mostly about students and lab tasks, not job candidates, so each step below says what was measured and where the advice is ours.

Start learning No account needed

1. Know what the interview asks for

A typical coding interview gives you a problem you have not seen, a shared editor or a whiteboard, and a person watching while you write code and explain your thinking. In a 2025 survey of 131 candidates who were preparing, the authors report that candidates rarely trained in settings like that and that their courses did little to help. If you are changing careers, that is a reason to practice the way the interview runs, not only to solve problems alone and in silence. We found no study that measures which preparation plan leads to job offers, so the advice below is our reading of narrower evidence.

2. Learn patterns before problems

A pattern is a reusable shape of solution, such as two pointers moving toward each other, a hash map of what you have seen, or a window sliding over an array. Learn one pattern at a time from a single worked example, then do a few problems that use it. Chi and colleagues watched students study worked examples of physics problems and found that the students who did better explained the steps to themselves and linked each step to a principle, and that the students who did worse relied on the examples when they solved new problems. That was physics, not interviews, so applying it to patterns is our suggestion.

Here is a worked example to do on paper before you run anything. A function finds two numbers in a sorted list that add up to a target:

def pair_sum(a, target):
    lo, hi = 0, len(a) - 1
    while lo < hi:
        s = a[lo] + a[hi]
        if s == target:
            return (lo, hi)
        if s < target:
            lo += 1
        else:
            hi -= 1
    return None

Predict what pair_sum([1, 3, 4, 6, 8, 11, 15], 14) returns and how many times the loop body runs. Write one row per pass with columns for lo, hi and the sum, then run it and compare. A mismatch tells you which step you misread.

checklohia[lo]a[hi]sum
10611516
20511112
31531114

The function returns (1, 5) after 3 checks. A sum of 16 is above 14, so the right pointer moves left, because nothing paired with 15 can be small enough. A sum of 12 is below 14, so the left pointer moves right.

Next, predict the cost. Each check moves one pointer one step inward, so the loop runs at most one fewer time than the list has items. We ran the code on lists of 1,000 and 1,000,000 items. The most checks needed were 999 for 1,000 items, over all targets we tried, and 999,999 for 1,000,000 items with a target that is not in the list. Two nested loops over all pairs would need up to 499,500 and 499,999,500,000 checks. The script is scripts/interview-two-pointer-worked-example.py in the Professor Turing repository, and it asserts each number above.

Now explain it aloud, as if to the interviewer: "The list is sorted, so the smallest and largest values bound any sum. If the sum is too big, the largest value cannot be part of any answer, so I drop it. If it is too small, the smallest cannot, so I drop that. Each check removes one candidate, so the cost grows in step with the list." If you cannot say why a pointer moves, that is the step to work on.

One change to try: write while lo <= hi instead of while lo < hi. Trace the correct and the changed version on [2, 5, 9] with target 10. The correct loop returns None, since no two different items add up to 10. The changed loop returns (1, 1), pairing 5 with itself.

3. Redo a problem cold after three days

After you solve a problem, close it. About three days later, open a blank page and solve it again without the notes or your old code, then compare and mark what you missed. Roediger and Karpicke had students study passages and then either restudy them or take recall tests. After 5 minutes restudying did better. After 2 days and after a week, the tested group kept substantially more. Their material was prose, not code, so for programming this is our reading.

The gap is our suggestion as well. Cepeda and colleagues combined 839 assessments of spacing in 317 experiments and found that the gap that gave the most retention grew as the time until the test grew. We found no study that tests a schedule for interview problems, so three days is a starting point to adjust: if you cannot redo a problem, redo it again a day or two later, and if you can, leave a longer gap.

4. Narrate while you solve

Say what you are doing as you do it, in the order you would in the interview: restate the problem, name the pattern you think applies and why, say what you will try first, then say what each line is for as you write it. At the end, give an example input, trace it aloud, and state the cost.

Behroozi and colleagues ran a randomized trial with 48 computer science students who solved whiteboard problems either alone in a private room or in front of an interviewer. Performance was reduced by more than half for the students who were watched, and their stress and mental load were higher. The trial describes how a normal interview goes for students; it does not test a way to prepare for it. Our suggestion is to practice aloud alone first, so the explaining is not new to you, then with a friend or a recording, so that being watched is not new either.

5. Keep an error log

After each problem, write one line for each mistake: what you wrote or thought, what was correct, and the missing step in one sentence, such as "moved the left pointer when the sum was too big, because I forgot the list is sorted." Add the pattern name. Once a week, pick lines from the log and redo those problems cold, as in step 3. You also have the log to read the night before an interview, which a pile of solved problems does not give you.

We found no study of error logs for interview preparation. The reasoning is a combination of the two findings above: a line in the log names the step you were missing, and redoing the problem cold after a gap tests whether you now have it.

Can I just solve more problems?

More problems may help when each one is followed by a cold redo and an explanation. The 2025 survey describes what candidates did, not whether it worked. If you have solved a problem by reading its solution, you have not yet shown that you can write it, so the cold redo is the check.

What the sources found, and their limits

Bell, Thomas, Lee and Brown, 2025. A survey of 131 candidates actively preparing for technical interviews. The authors report that candidates rarely train in authentic settings and that courses fail to support preparation. Limits: self-report from one survey, and we read the abstract only. Source: arXiv 2507.02068, abstract read through the arXiv API on 2026-11-23.

Chi, Bassok, Lewis, Reimann and Glaser, 1989. Talk-aloud protocols from students studying worked examples of mechanics problems. "Good" students generated more self-explanations and relied less on the examples afterward. Limits: physics students, a small lab study, and we read the abstract only. Source: Cognitive Science, 1989, DOI record, abstract read through the Crossref API on 2026-11-23.

Roediger and Karpicke, 2006. Two experiments with students who studied prose passages, then restudied or took one or three free-recall tests with no feedback. After 5 minutes restudying did better; after 2 days and a week testing gave substantially greater retention. Limits: prose in a lab, not code, and we read the abstract record. Source: Europe PMC record, 2006, abstract read through the Europe PMC API on 2026-11-23.

Cepeda, Pashler, Vul, Wixted and Rohrer, 2006. A meta-analysis of 839 assessments of distributed practice in 317 experiments in 184 articles. The study gap that gave maximal retention increased as the time until the test increased. Limits: verbal recall tasks, and we read the abstract only. Source: Europe PMC record, Psychological Bulletin, 2006, abstract read through the Europe PMC API on 2026-11-23.

Behroozi, Shirolkar, Barik and Parnin, 2020. A randomized controlled trial with 48 computer science students solving whiteboard problems in private or public settings. Performance was reduced by more than half when an interviewer watched, and stress and cognitive load were higher. Limits: students, not job candidates, and we read the abstract only. Source: ESEC/FSE 2020, DOI record, abstract read through the Semantic Scholar API on 2026-11-23.

Our own numbers. The checks (3 for the example, 999 and 999,999 for the two list sizes, and 499,500 and 499,999,500,000 for nested loops) come from interview-two-pointer-worked-example.py, which asserts each one.

How Professor Turing helps

Professor Turing is a tutor for adults learning any subject, in college or on their own. It asks you questions instead of giving the final answer, does not grade a bare guess, and remembers what you got wrong. No account is needed to start. That includes people moving into software from another field.

Bring a problem you are working on, such as the pair sum above. Its first reply asks about your attempt, such as what you tried or where it stops making sense, before it teaches anything. If you send an answer with no steps, such as "it returns (1, 5)", it asks how you got there instead of saying right or wrong, and when you stay stuck it changes its approach and makes the next step smaller. Later in a session it can offer a short test without help, scored apart from the tutoring, so you can tell what you can do alone from what the tutor carried you through.

It cannot see handwriting or photos, so do your trace tables on paper yourself and say what you found. It does not run your code or play a live interviewer. You must be 18 or older. Guest conversations are deleted 7 days after your last activity; with an account they are kept while the account is active.

FAQ

How many problems should I solve? We found no study that gives a number. Pick a count of patterns you can redo cold, and add problems when the error log shows a gap.

Which language should I use? Use the one you will be allowed to use in the interview and write comfortably. The example above is Python, and the steps do not depend on the language.

Can the tutor act as my interviewer? No. It asks you questions about a problem and does not watch you write code. For practice with a person watching, ask a friend, as step 4 suggests.

Start with what you're working on

Tell the tutor which problem or pattern you are working on and let it ask you the questions.

Start learning No account needed

See also: all study guides