Why is the brute-force approach less ideal here?
Practice this question from Number of Islands - Grid DFS Pattern Practice Quiz, with options and an explanation.
Question
Why is the brute-force approach less ideal here?
Option A — Correct answer
It compares land cells globally instead of using local graph neighbors.
Option B
It is always constant time
Option C
It avoids graph traversal entirely
Option D
It works only on sorted arrays
Explanation
It compares land cells globally instead of using local graph neighbors.