tack to keep track of max element
static Stack < int > trackStack = new Stack < int > ( ) ; public void push ( int x ) { mainStack . Push ( x ) ; if ( mainStack . Count == 1 ) { trackStack . Push ( x ) ; return ; }