Skip to content

Cheat sheets

Four pages, made to be kept open in a tab the week before an interview, or printed. Every row links to the lesson that animates it; the guide on the left keeps your place.

  1. Big-O cheat sheet

    Time and space complexity of every data structure and algorithm on BytePatterns, from hash tables to Dijkstra, each row linked to its animated lesson.

    How the common complexity classes growSteps against input size n from 1 to 20, cut off at 60 steps. O(1) stays flat and O(log n) barely rises; O(n) climbs steadily and O(n log n) a little faster; O(n²) leaves the chart before n reaches 8, O(2ⁿ) before 6 and O(n!) before 5.15101520input size n →steps →O(n!)O(2n)O(n2)O(n log n)O(1)O(log n)O(n)

    78 rows · 94 lessons linked · updated

    Growth orders

    • O(1)constant · Constant or logarithmic
    • O(log n)logarithmic · Constant or logarithmic
    • O(n)linear · Linear or n log n
    • O(n log n)linearithmic · Linear or n log n
    • O(n²)quadratic · Polynomial
    • O(2ⁿ)exponential · Exponential or factorial
    • O(n!)factorial · Exponential or factorial
    Open step 01
  2. Interview patterns cheat sheet

    The coding-interview patterns worth knowing: when to reach for each, the signals in a problem statement that give it away, and a lesson and practice for each.

    • Two pointersA sorted array or a string where a pair, a partition or a palindrome is decided from both ends.
    • Sliding windowThe answer is a contiguous run and growing or shrinking it by one element updates the state cheaply.
    • Prefix sumsMany range-sum questions over the same array, or a subarray sum that must equal k.
    • Hash map lookupsYou keep asking "have I seen this before?" or "how many of these are there?" inside a loop.

    23 patterns · a lesson and practice for each · updated

    Two pointers: the signals

    • →sorted array + find a pair / triple with a target sum
    • →remove duplicates or move items in place
    • →palindrome, reverse, or compare from both ends
    Open step 02
  3. SQL interview cheat sheet

    Execution order, joins, window functions, NULL, indexes and the classic interview queries, each with the rows SQLite returned.

    • FROM / JOINBuilds the rows: every table, every join.
    • WHEREKeeps the rows whose test is TRUE.
    • GROUP BYFolds the rows into one row per group.
    • HAVINGKeeps the groups whose test is TRUE.
    • SELECTComputes the output columns and names the aliases; window functions run here.

    10 interview queries · 9 topics · every result run on SQLite · updated

  4. Python interview cheat sheet

    The Python an interviewer expects: data structure costs, sorting, strings, itertools, traps and ten templates, each snippet with the output it printed.

    a = [3, 1, 4]
    a.append(1)      # O(1) amortized
    a.insert(0, 9)   # O(n): shifts every item
    print(a)
    print(a.pop(), a.pop(0))  # O(1), O(n)
    print(4 in a)    # O(n) scan

    54 snippets · 10 templates · every output from a real run · updated

    Templates

    Open step 04