~/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.
53 problems
Interview roadmap
Graphs Grids and networks: BFS, DFS, cycles, ordering.
BFS / multi-source BFS guide
- Play first: The Maze 1-minute game Breadth-first search
- Shortest hop counts from one node basics py · c++ · java easy
- Museum: fewest doors to an exhibit code the boss py · c++ · java easy
- Shortest Path in Binary Matrix py · c++ · java medium
- Rotting Oranges ▶ boss game py · c++ · java medium
- Distance to nearest zero py · c++ · java medium
- Walls and Gates py · c++ · java medium
- Open the Lock py · c++ · java medium
- Word Ladder py · c++ · java hard
More practice: 8 problems
- 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 py · c++ · java medium
- Bus Routes GooglePinterest py · c++ · java hard
- Fastest commute on a mode grid assessment 3 levels Databricks py · c++ · java hard
- Office floor: bathrooms and cakes assessment 3 levels Snowflake py · c++ · java hard
- Infection spread (multi-part simulation) assessment 4 levels OpenAI py · c++ · java hard
DFS and connected components guide
- Play first: The Burning Isles 1-minute game Flood fill (DFS or BFS on a grid)
- Everything reachable from a node basics py · c++ · java easy
- Storm outage: neighbourhoods without a generator py · c++ · java easy
- Island Perimeter py · c++ · java easy
- Number of Islands code the boss py · c++ · java medium
- Max Area of Island Snapchat py · c++ · java medium
- Clone Graph py · c++ · java medium
- Pacific Atlantic Water Flow py · c++ · java medium
- Use every boarding pass exactly once Citadel py · c++ · java hard
More practice: 10 problems
- Find the Town Judge py · c++ · java easy
- Connect all cities with fewest roads py · c++ · java easy
- Cutting a branch out of a forest Pinterest py · c++ · java easy
- Number of Connected Components in an Undirected Graph py · c++ · java medium
- Surrounded Regions py · c++ · java medium
- Evaluate Division py · c++ · java medium
- Minimum servers to activate Airbnb py · c++ · java hard
- Chain every word end to start py · c++ · java hard
- Critical Connections in a Network py · c++ · java hard
- Count and map a machine tree by messages assessment 3 levels OpenAI py · c++ · java hard
Cycle detection guide
- Play first: The Haunted Halls 1-minute game Cycle detection (three colours)
- Does a directed graph have a cycle? basics py · c++ · java easy
- Spreadsheet: show the circular reference py · c++ · java medium
- Find Eventual Safe States code the boss py · c++ · java medium
- Bootloader loop: detect and repair assessment 3 levels Anthropic py · c++ · java medium
Bipartite graphs / 2-colouring guide
- Play first: The Clan War 1-minute game Bipartite check (two-coloring with BFS)
- Colour by BFS depth, find the bad edges basics py · c++ · java easy
- Most edges you can add to a tree and stay bipartite py · c++ · java easy
- Is Graph Bipartite? code the boss py · c++ · java medium
- Day and night shifts with fixed staff py · c++ · java medium
Topological sort (Kahn's) guide
- Play first: The Quest Board 1-minute game Topological sort (Kahn's algorithm)
- Check a topological order basics py · c++ · java easy
- Course Schedule py · c++ · java medium
- Course Schedule II code the boss py · c++ · java medium
- What to rebuild, and in what order py · c++ · java medium
- Minimum Height Trees py · c++ · java medium
- Inherited permissions with allow and disallow assessment 2 levels Snowflake py · c++ · java medium
- Alien Dictionary py · c++ · java hard
More practice: 4 problems
- Build steps that run alone DatabricksMeta py · c++ · java medium
- Best run down the mountain Airbnb py · c++ · java medium
- Course Schedule IV py · c++ · java medium
- Spreadsheet with formula dependencies assessment 2 levels OpenAI py · c++ · java hard