If stack becomes empty , then no element is greater on left side . Else top of stack is previous greater .
if ( s . empty ( ) == true ) System . out . print ( " - 1 , ▁ " ) ; else System . out . print ( s . peek ( ) + " , ▁ " ) ; s . push ( arr [ i ] ) ; } }