Why is scanning forward from every day too slow?
Practice this question from Daily Temperatures - Monotonic stack Pattern Practice Quiz, with options and an explanation.
Question
Why is scanning forward from every day too slow?
Option A — Correct answer
It may scan many later days for each day
Option B
It is always O(log n)
Option C
It uses recursion
Option D
It cannot handle equal temperatures
Explanation
Each day may scan many later days, causing O(n^2) work.