WHY THIS code give segmentation error?

Please help mee in this code.It is showing segmentation fault…
https://ide.geeksforgeeks.org/dOiTn0fLsK

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

https://codeforces.com/problemset/problem/1374/C

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 : https://codeforces.com/contest/1374/submission/85371917

1 Like