Given a 1D integer array A containing N integers, the array A is circular.
A circular array is one where the next element of the last element is the first element.
You need to find next immediate larger number for every element in the array A.
1 <= N <= 105
1 <= A[i] <= 106
First argument is an integer array A.
Return a 1D integer array of size N representing next greater element for each element in the array A.
A = [3, 1, 3, 4]
A = [3, 2]
[4, 3, 4, -1]
3's next greater is 4 1's next greater is 3 3's next greater is 4 again 4 will look to the beginning, but find nothing, so -1
3 will look to the end, but find nothing, so -1 2 will look to the beginning, and find 3
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.