If current element is greater than the top element of track stack , push the current element to track stack otherwise push the element at top of track stack again into it .
if ( x > trackStack . Peek ( ) ) trackStack . Push ( x ) ; else trackStack . Push ( trackStack . Peek ( ) ) ; } public int getMax ( ) { return trackStack . Peek ( ) ; } public void pop ( ) { mainStack . Pop ( ) ; trackStack . Pop ( ) ; } } ;