Coding Interview Prep Cheat Sheet

Coding interview preparation — data structures, algorithms, problem-solving patterns, time complexity, and a structured approach to whiteboard coding.

Last Updated: July 15, 2025

Core Data Structures

StructureOperationsWhen to Use
Array/ListAccess O(1), Insert O(n)Indexed access, fixed size
Hash Map/DictAll O(1) avgLookups, counting, caching
StackPush/Pop O(1)DFS, backtracking, undo
QueueEnq/Deq O(1)BFS, scheduling, buffers
Binary HeapMin/Max O(1), Insert O(log n)Priority queues, top-K
Hash SetAdd/Remove O(1)Deduplication, membership

Algorithm Patterns

PatternSignalExample Problems
Two PointersSorted array, subarray, palindromesTwo Sum II, 3Sum, Container with Most Water
Sliding WindowContiguous subarray/substringLongest substring without repeats
Binary SearchSorted, search space pruningSearch rotated array, find peak
BFS/DFSTree, graph, shortest path unweightedNumber of islands, word ladder
Dynamic ProgrammingOptimal substructure, overlappingKnapsack, LCS, coin change

Time Complexity Quick Reference

NMax Acceptable Complexity
N ≤ 10O(N!) — brute force permutations
N ≤ 20O(2^N) — recursion, subsets
N ≤ 100O(N³) — Floyd-Warshall, triple loop
N ≤ 1,000O(N²) — nested loops, insertion sort
N ≤ 10⁵O(N log N) — sorting, heaps
N ≤ 10⁶O(N) — linear scan, hash map
N > 10⁷O(log N) or O(1) — binary search, math

Interview Strategy

1. Clarify (2 min)
Input format? Edge cases? Constraints? Duplicates?
2. Brute Force (2 min)
State the naive approach, note its complexity
3. Optimize (5 min)
Identify pattern, propose optimized approach
4. Code (10 min)
Clean, named variables, handle edge cases
5. Test (3 min)
Walk through with example, check edge cases
Pro Tip: Talk through your approach before writing code. Interviewers care more about your thought process than perfect syntax. Say the brute force first, then optimize.
Part of the Empire Builder Network