Back to course home
0% completed
Vote For New Content
Next Greater Element II (medium)
Problem Statement
Given a circular integer array nums, return the array containing the next greater number for each element in nums.
A next greater number of a number num is the first greater number than the current number in its traversing-order in the array, which means you could search circularly to find its next greater number. If the next greater element doesn't exist, return -1 for the particular number number.
Examples
- Example 1:
- Input: nums =
[2, 1, 2, 4, 3] - Expected Output:
[4, 2, 4, -1, 4] - Justification: For `2
- Input: nums =
.....
.....
.....
Like the course? Get enrolled and start learning!