WORLD 6
GRAPHS
Grids, dependencies and travel times: search outward, put steps in order, find the fastest route.
STAGE 0 Graphs tutorial
0:00 / 0:00
The move
Explore outward from a start. Breadth-first search uses a queue and ripples out ring by ring (fewest steps); depth-first search dives deep with a stack or recursion. Mark every node you visit so you never loop.
- Spot it
- The problem says connected, neighbours, islands, network, path, prerequisites or fewest steps. A grid is a graph too.
- Cost
- Each node and edge is handled once: O(V + E) time and O(V) space for the visited set.
15 STAGES Graphs problems
☆☆☆☆☆ Clear 5 to finish this world.
MEDIUM1:39Number of Islands
Grid searchLC 200▶ START
MEDIUM1:40Rotting Oranges
BFSLC 994▶ START
MEDIUM1:33Pacific Atlantic Water Flow
Grid searchLC 417▶ START
MEDIUM1:36Surrounded Regions
Grid searchLC 130▶ START
HARD1:46Longest Increasing Path in a Matrix
Grid searchLC 329▶ START
MEDIUM1:34Clone Graph
GraphsLC 133▶ START
MEDIUM1:44Course Schedule
Topological sortLC 207▶ START
MEDIUM1:42Course Schedule II
Topological sortLC 210▶ START
MEDIUM1:36Network Delay Time
Shortest pathLC 743▶ START
MEDIUM1:46Cheapest Flights Within K Stops
Shortest pathLC 787▶ START
HARD1:32Swim in Rising Water
Shortest pathLC 778▶ START
HARD1:48Reconstruct Itinerary
Eulerian pathLC 332▶ START
MEDIUM1:40Redundant Connection
Union-findLC 684▶ START
MEDIUM1:35Min Cost to Connect All Points
Minimum spanning treeLC 1584▶ START
HARD1:49Word Ladder
BFSLC 127▶ START