If the element at top of stack is less than the current element then pop the stack top and keep updating the value of h3
while ( ! st . empty ( ) && st . top ( ) < arr [ i ] ) { h3 = st . top ( ) ; st . pop ( ) ; }