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

Graphs problems
#ProblemDifficultyVideoAI round
1Number of IslandsMediumAI round
2Rotting OrangesMediumAI round
3Word LadderHardAI round
4Number of ProvincesMedium—
5Clone GraphMedium—
6Max Area of IslandMedium—
7Surrounded RegionsMedium—
8Flood FillEasy—
9Is Graph Bipartite?Medium—
10Pacific Atlantic Water FlowMedium—
11Accounts MergeMedium—
12Shortest Path in Binary MatrixMedium—
13Redundant ConnectionMedium—
14Critical Connections in a NetworkHard—
15Keys and RoomsMedium—
16Open the LockMedium—
17Making A Large IslandHard—
18Trapping Rain Water IIHard—
19Shortest Path in a Grid with Obstacles EliminationHard—
20Bus RoutesHard—
21Jump Game IIIMedium
22Graph Valid TreeMedium—
23Walls and GatesMedium—
24Number of Connected Components in an Undirected GraphMedium—
25Number of Distinct IslandsMedium—
26Count Servers that CommunicateMedium
27Shortest Distance from All BuildingsHard—
28The MazeMedium—
29Minimum Knight MovesMedium—

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 round