1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress

Number of Islands
DFS/BFS on grid:
Iterate all cells
If land ('1'), run DFS/BFS to mark entire island as visited
Increment count
Turn visited land into water or use visited set

Flood Fill
DFS/BFS from starting pixel:
If new color == original, return
Traverse neighbors (4 directions)
Recolor all connected same-color cells

01 Matrix (Multi-source BFS)
BFS from all 0s:
Push all 0 cells into queue
Initialize others as ∞
BFS outward, updating distance = prev + 1
Shortest distance to nearest 0

Rotting Oranges (Multi-source BFS)
BFS from all rotten oranges:
Push all rotten (2) into queue
Count fresh oranges
Each level = 1 minute, rot neighbors
Decrease fresh count
If fresh becomes 0 → return minutes, else -1

Clone Graph
DFS/BFS + hashmap:
Map original node → cloned node
For each node, clone neighbors recursively
Avoid revisiting using map
Graph copy via mapping

Pacific Atlantic Water Flow
Reverse DFS/BFS:
Start from ocean edges (Pacific & Atlantic separately)
Move inward only to higher/equal heights
Mark reachable cells for each ocean
Intersection = answer

Course Schedule
Cycle detection in directed graph:
Build adjacency list
DFS with 3 states: unvisited, visiting, visited
If visiting node seen again → cycle
If no cycle → possible to finish
Topological sort concept

Max Area of Island
DFS/BFS on grid:
Iterate all cells
If land (1), run DFS/BFS to explore connected island
Count number of cells in this island
Track maximum area seen
Mark visited by turning land to water or using visited set