~/problems
Problems
Basics first, then the classics, then company-style assessments. Every problem has tests you run right here; multi-level ones unlock as you go. See the roadmap.
Interview roadmap
Graphs
Grids and networks: BFS, DFS, cycles, ordering.
50 problems
Interview roadmap
Graphs Grids and networks: BFS, DFS, cycles, ordering.
BFS / multi-source BFS guide
- Basics: shortest hop counts from one node basics py · c++ · java easy
- Museum: fewest doors to an exhibit py · c++ · java easy
- Rotting Oranges py · c++ · java medium
- Distance to nearest zero py · c++ · java medium
- Infection spread (multi-part simulation) 4 levels OpenAI hard
- Fastest commute on a mode grid 3 levels Databricks hard
- Office floor: bathrooms and cakes 3 levels Snowflake hard
- Score a tile-laying board Airbnb py · c++ · java easy
- Tree nodes whose distances form a Pythagorean triple py · c++ · java easy
- Friend suggestions by mutual friends CitadelOracle py · c++ · java easy
- Count Objects in Pin Pinterest medium
- Walls and Gates py · c++ · java medium
- Word Ladder py · c++ · java hard
- Open the Lock py · c++ · java medium
DFS and connected components guide
- Basics: everything reachable from a node (iterative DFS) basics py · c++ · java easy
- Storm outage: neighbourhoods without a generator py · c++ · java easy
- Number of Islands py · c++ · java easy
- Max Area of Island Snapchat py · c++ · java easy
- Clone Graph medium
- Pacific Atlantic Water Flow py · c++ · java medium
- Connect all cities with fewest roads py · c++ · java easy
- Count and map a machine tree by messages 3 levels OpenAI hard
- Number of Connected Components in an Undirected Graph py · c++ · java easy
- Minimum servers to activate Airbnb py · c++ · java hard
- Use every boarding pass exactly once Citadel py · c++ · java hard
- Cutting a branch out of a forest Pinterest py · c++ · java easy
- Surrounded Regions py · c++ · java medium
- Chain every word end to start py · c++ · java hard
- Evaluate Division py · c++ · java medium
- Island Perimeter py · c++ · java easy
- Find the Town Judge py · c++ · java easy
Cycle detection guide
- Basics: does a directed graph have a cycle? basics py · c++ · java easy
- Spreadsheet: show the circular reference easy
- Find Eventual Safe States py · c++ · java medium
- Bootloader loop: detect and repair 3 levels Anthropic hard
Bipartite graphs / 2-colouring guide
- Basics: colour by BFS depth, find the bad edges basics py · c++ · java easy
- Day and night shifts with fixed staff easy
- Is Graph Bipartite? py · c++ · java easy
- Most edges you can add to a tree and stay bipartite py · c++ · java easy
Topological sort (Kahn's) guide
- Basics: check a topological order basics py · c++ · java easy
- What to rebuild, and in what order easy
- Course Schedule py · c++ · java easy
- Course Schedule II py · c++ · java easy
- Alien Dictionary py · c++ · java medium
- Spreadsheet with formula dependencies 2 levels OpenAI medium
- Inherited permissions with allow and disallow 2 levels Snowflake medium
- Best run down the mountain Airbnb medium
- Build steps that run alone DatabricksMeta py · c++ · java medium
- Minimum Height Trees py · c++ · java medium
- Course Schedule IV py · c++ · java medium