Why is the brute-force approach less ideal here?

Practice this question from Longest Consecutive Sequence - Hash Set Pattern Practice Quiz, with options and an explanation.

Question

Why is the brute-force approach less ideal here?

Option A — Correct answer

Sorting costs O(n log n) and repeated expansion wastes work.

Option B

It is always constant time

Option C

It uses no repeated work

Option D

It requires binary tree recursion

Explanation

Sorting costs O(n log n) and repeated expansion wastes work.

Longest Consecutive Sequence - Hash Set Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker