WHY THIS code give segmentation error?

Please help mee in this code.It is showing segmentation fault…

please help It is urgent…

Why?

Please link to the Problem you are trying to solve so that we know the Input Format, Constraints, etc.

2 Likes

Please can u see now why is this error displaying??

When s1.empty() && str[i] == ‘)’, then it will try to access top most element which is not present and thus produces SIGSEV.

BTW you can solve it without stack : Submission #85371917 - Codeforces

1 Like