LeetCode MEDIUM 503 Next Greater Element II Summary
Generated by Codex with GPT-5
Quick facts
- Difficulty:
MEDIUM - Problem: Next Greater Element II
- Main tags:
Array,Stack,Monotonic Stack
What the problem is really asking
The input is an integer array nums, but the array is circular. After the last index, the scan wraps back to index 0.
For each index i, the task is to find the first value that is strictly greater than nums[i] when walking forward through this circular array. If no greater value appears before returning to i, the answer for that index is -1.