https://ide.codingblocks.com/s/364041 dont change the whole code
Redundant parenthesis is giving segmentation fault pls check and also check the output
Before performing the s.top() operation you must always check if the stack is empty or not. s.top() operation on an empty stack will give segmentation fault. So make the necessary changes now.
You can verify the approach from here Redundant parenthesis