Before any code, find the inputs that could break you.
Say “Can I assume the input is never empty?”
E
Explain the solution
Talk through a few approaches out loud. Agree on one with your interviewer, then type.
Say “Before I write anything, here’s my plan.”
A
Apply the algorithm
Write the code. With a plan, it’s the short part.
Say “I’ll write the steps as comments first.”
C
Check all cases
Walk the edge cases. Empty input, one element, the one nobody tried.
Say “Let me run example one through the code.”
H
Highlight the trade-offs
Say the time and space cost, and what you gave up.
Say “Time is O(n), each item enters the window once and leaves once. Space is O(k).”
A sample section: the T step in full
This is what each step looks like in the cheat sheet. The full sheet has all five, 29 patterns and 40 algorithms.
T
Test cases
Before any code, find the inputs that could break you.
Ask yourself
What are the biggest and smallest inputs?
Which three edge cases would break a naive solution?
What do I return when there is no answer?
Say out loud
“Can I assume the input is never empty?”
“Let me walk the example by hand first.”
Checklist
Walk the given example by hand and confirm the expected output.
Pick three edge cases from the edge-case checklist.
Write them down. They come back in C.
Ask the questions in the edge-case section before naming any algorithm.
Common miss Naming an algorithm before asking a single question.
Ask the interviewer, before you name an algorithm
What are the biggest and smallest inputs?
Can the input be empty, or have one element?
Can it have duplicates? Negatives? Zero?
Is the input sorted? Can I change it in place?
What do I return when there is no answer?
Can there be more than one valid answer? Does order matter?
Edge cases: Arrays and strings
Case
Example
What it breaks
empty, no input
[] or ""
index 0 reads crash, max() raises
one element
[7]
no pair, no neighbor, the loop never compares
all zeros
[0, 0, 0]
division, products, “the max is positive”
all the same value
[4, 4, 4]
distinct-window logic, dedupe, ties
negatives, mixed signs
[−2, 5, −1]
greedy, “the sum only grows”, abs tricks
duplicates
[3, 3, 3]
sets, unique-index assumptions, 3Sum skips
already sorted, reverse sorted
[1, 2, 3] and [3, 2, 1]
naive quicksort worst case, binary search needs it
max size
n = 100,000
O(n²) times out, recursion depth
max and min values
2,147,483,647
int overflow in sums, (lo + hi) / 2
whitespace, case, unicode
" a B é"
split, lower(), bytes vs characters
Want the rest?
The full cheat sheet is free: all five steps in depth, 29 patterns, 40 algorithms, data structures and Big-O. Join the list and it's yours, then new videos, system design breakdowns and the AI news worth your time.