if stack is not empty , then pop an element from stack . If the popped element is greater than next , then a ) print the pair b ) keep popping while elements are greater and stack is not empty
while ( s . empty ( ) == false && s . peek ( ) > arr [ i ] ) { mp . put ( s . peek ( ) , arr [ i ] ) ; s . pop ( ) ; }