← Whiteboard questions

Pattern

Trees

Most tree problems ask one question about a node and combine the answers from its children. Choose depth-first for questions about paths and shape, and breadth-first for questions about levels. The cost is usually O(n) time, with memory equal to the height.

Trees interview questions and solutions