Patterns to know


How to identify


Traversals in a nutshell

For node N:

Example tree:

      4
     / \
    2   5
   / \
  1   3

Common interview problems by category


⚡ Pro tip: Whenever you see “sum, max, height, balanced, depth, diameter,” think DFS recursion with a return value. Whenever you see “level, closest, shortest path, zigzag,” think BFS with a queue.


Contents