Given an array, find the next greater element G[i] for every element A[i] in the array. The Next greater Element for an element A[i] is the first greater element on the right side of A[i] in array.
G[i] for an element A[i] = an element A[j] such that j is minimum possible AND j > i AND A[j] > A[i]
Elements for which no greater element exist, consider next greater element as -1.
A : [4, 5, 2, 10]
[5, 10, 10, -1]
A : [3, 2, 1]
[-1, -1, -1]