Why is the direct scan baseline slow?

Practice this question from Next Greater Element I - Monotonic stack Pattern Practice Quiz, with options and an explanation.

Question

Why is the direct scan baseline slow?

Option A — Correct answer

It may scan nums2 repeatedly

Option B

It uses no loops

Option C

It cannot return -1

Option D

It always mutates nums1

Explanation

For each nums1 value, it may scan a suffix of nums2.

Next Greater Element I - Monotonic stack Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker