Overview
This section contains tree and graph problems from Google interviews.
- Delete a Tree — Delete every node in a binary tree individually, with a constant-memory follow-up.
- Remove Edges from a Tree — Compute connected component sizes after removing edges, using pre-calculated subtree sizes.
- Islands in a Tree — Count islands of 1-valued nodes in a binary tree, with follow-ups on distinct shapes via tree isomorphism.
- Walk Through Shadow Area — Find the path that minimizes sun exposure across a 2D plane with rectangular shadow areas.
- Find Largest Connected Graph — Build a geometric graph from 2D points with a distance threshold and find the largest connected component.
- Validate Sequence of Numbers — Determine if partial subsequences from multiple observers are consistent using topological sort.
- Blind Robot in a Maze — Find a command sequence that guarantees a blind robot escapes a maze from any starting position.