function to find just next greater element in left side
static int [ ] nextGreaterInLeft ( int [ ] a , int n ) { int [ ] left_index = new int [ MAX ] ; Stack < int > s = new Stack < int > ( ) ; for ( int i = n - 1 ; i >= 0 ; i -- ) {