Graphs
Model cells, people or words as nodes and their connections as edges, then explore with breadth-first or depth-first search. The tell is a grid, a network or a set of links, as in Number of Islands. It gives you connected groups and shortest paths in linear time.
29 problems · 5 with a video · 3 to practice in an AI round
| # | Problem | Difficulty | Video | AI round |
|---|---|---|---|---|
| 1 | Number of Islands | Medium | AI round | |
| 2 | Rotting Oranges | Medium | AI round | |
| 3 | Word Ladder | Hard | AI round | |
| 4 | Number of Provinces | Medium | — | |
| 5 | Clone Graph | Medium | — | |
| 6 | Max Area of Island | Medium | — | |
| 7 | Surrounded Regions | Medium | — | |
| 8 | Flood Fill | Easy | — | |
| 9 | Is Graph Bipartite? | Medium | — | |
| 10 | Pacific Atlantic Water Flow | Medium | — | |
| 11 | Accounts Merge | Medium | — | |
| 12 | Shortest Path in Binary Matrix | Medium | — | |
| 13 | Redundant Connection | Medium | — | |
| 14 | Critical Connections in a Network | Hard | — | |
| 15 | Keys and Rooms | Medium | — | |
| 16 | Open the Lock | Medium | — | |
| 17 | Making A Large Island | Hard | — | |
| 18 | Trapping Rain Water II | Hard | — | |
| 19 | Shortest Path in a Grid with Obstacles Elimination | Hard | — | |
| 20 | Bus Routes | Hard | — | |
| 21 | Jump Game III | Medium | ||
| 22 | Graph Valid Tree | Medium | — | |
| 23 | Walls and Gates | Medium | — | |
| 24 | Number of Connected Components in an Undirected Graph | Medium | — | |
| 25 | Number of Distinct Islands | Medium | — | |
| 26 | Count Servers that Communicate | Medium | ||
| 27 | Shortest Distance from All Buildings | Hard | — | |
| 28 | The Maze | Medium | — | |
| 29 | Minimum Knight Moves | Medium | — |
Sort by what interviews ask
Sign in to see how many companies ask each problem, sort all 500 by it or by likes, and tick off what you solve.
Practice in an AI round
Three of these are AI rounds: 30 minutes, an AI agent beside your code, then a scored report.
Practice Number of Islands in an AI roundYour first AI round is free.