Graph
Graph problems model entities and their connections, then ask about paths, reachability, components, or cycles. The first decision is the representation (adjacency list versus matrix); the second is which traversal — BFS, DFS, or a shortest-path algorithm — fits.
12 LeetCode problems solved with the Graph pattern. Practice them with spaced repetition so the pattern sticks.
- Cheapest Flights Within K StopsMEDIUM · O(k * E)
- Clone GraphMEDIUM · O(V + E)
- Course Schedule IVMEDIUM · O(n^3 + q)
- Evaluate DivisionMEDIUM · O(q * (n + e))
- Find the Town JudgeEASY · O(n + e)
- Min Cost to Connect All PointsMEDIUM · O(n^2)
- Minimum Height TreesMEDIUM · O(n)
- Network Delay TimeMEDIUM · O(E log V)
- Number of ProvincesMEDIUM · O(n^2)
- Path With Minimum EffortMEDIUM · O(R*C*log(maxH))
- Reconstruct ItineraryHARD · O(E log E)
- Swim in Rising WaterHARD · O(n^2 log n)
See the full solution
The complete approach, reference solutions in 5 languages, and a step-by-step visualization — then add this problem to your spaced-repetition schedule.
Start free →