iterate through the stack Use string ( int , char ) in order to replicate the character multiple times and convert into string then add in front of output string
String ans = " " ; while ( st . Count > 0 ) { char c = st . Peek ( ) . c ; int cnt = st . Peek ( ) . ctr ; while ( cnt -- > 0 ) ans = c + ans ; st . Pop ( ) ; } return ans ; }