What is the main signal for Monotonic Stack: Next Element and Subarray Contribution?
Practice this question from Quiz: Monotonic Stack: Next Element and Subarray Contribution, with options and an explanation.
Question
What is the main signal for Monotonic Stack: Next Element and Subarray Contribution?
Option A — Correct answer
The problem asks for next greater/smaller, visibility, histogram area, or sum over subarray minimum/maximum.
Option B
The input has no constraints.
Option C
The sample output is small.
Option D
The question uses only one variable.
Explanation
Pattern choice starts from constraints and invariant.