What does Next Greater Element I need for each nums1 value?

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

Question

What does Next Greater Element I need for each nums1 value?

Option A — Correct answer

The next greater value to the right in nums2

Option B

The previous smaller value

Option C

The index in nums1 only

Option D

The sorted position

Explanation

It needs the next greater value to the right in nums2, or -1.

Next Greater Element I - Monotonic stack Pattern Practice Quiz

All questions · Next question

Open on QuizMaker