pattern / HARD
Traverse and analyze graph structures
complexity
time
O(V + E)
space
O(V)
02' — visual
interactive
Maximum sum subarray
03'
mental
model.
Represent graph as adjacency list. Use BFS with queue or DFS with stack/recursion. Track visited set.
Graph algorithms form a major category. Includes BFS, DFS, shortest path, MST, topological sort, and union find patterns.
when to use ✓
when not ✗
04'
Network of nodes and edges
Shortest path problems
Connected components
Dependency resolution
05'
1# Beginner: Fixed-size sliding window2def max_sum_k(nums, k):3 n = len(nums)4 if n < k:5 return 06 window_sum = sum(nums[:k])7 max_sum = window_sum8 for i in range(k, n):9 window_sum += nums[i] - nums[i - k]10 max_sum = max(max_sum, window_sum)11 return max_sum
common mistakes
interview tips
06'
0 curated problems from LeetCode
No questions found for this pattern yet.
07'