Next Greater Element II

Given a circular integer array, return the next greater number for every element. The next greater number is the first greater number to its next in the array. Search circularly if necessary. If it doesn't exist, return -1 for that number.

Constraints

  • 1 <= nums.length <= 10^4
  • -10^9 <= nums[i] <= 10^9
Saving… · 2 lines
class Solution:
def nextGreaterElements(self, nums: List[int]) -> List[int]:
Console

Click Run to execute sample tests.