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 . Count != 0 && s . Peek ( ) > arr [ i ] ) { mp . Add ( s . Peek ( ) , arr [ i ] ) ; s . Pop ( ) ; }