What does the monotonic stack precompute?

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

Question

What does the monotonic stack precompute?

Option A — Correct answer

A map from value to next greater value

Option B

Only the maximum value

Option C

A prefix sum table

Option D

A palindrome table

Explanation

It precomputes a map from each value in nums2 to its next greater value.

Next Greater Element I - Monotonic stack Pattern Practice Quiz

All questions · Previous question · Next question

Open on QuizMaker