Next Greater Element Ii

easy
Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1: 1 <= nums.length <= 10^4
2: -10^9 <= nums[i] <= 10^9

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
3
1
2
1
Output
3
2
-1
2
Previous
Next Greater Element I
Next
Validate Stack Sequences

Related Questions