Which optimized pattern solves this lesson cleanly?
Practice this question from Number of Islands - Grid DFS Pattern Practice Quiz, with options and an explanation.
Question
Which optimized pattern solves this lesson cleanly?
Option A — Correct answer
Scan once and DFS from each newly found land cell.
Option B
Nested loops without visited state
Option C
Two pointers on a sorted array
Option D
Character frequency counting only
Explanation
Scan once and DFS from each newly found land cell.