In multiple Test Cases How to use Stack I am Getting Segmentation Fault Pls Correct My Code And Tell Me

Please Help to remove Segmentation Fault .
I guess it is due to that stack was not deleted and defined again ?

hello @yashratnani6 what is the question?
could you please elborate what you are trying to do?

hey @yashratnani6 i have corrected and commented the mistake in the code.


if you have anydoubt you can ask here.
Happy Learning !!

But Removing Else condition is giving me wrong Answer
https://codeforces.com/problemset/problem/1428/C
Here is the Question
My Logic is 100% correct I know

@yashratnani6 see this:


in this code see for the last test case in this the last 2 characters forming AB then they will also eliminate in that case.
we have to handle these test cases as well.
have you seen the editorial for this question?

please see this code as well:


its much simple then yours.
Happy Learning !!

Thank You for helping
1 Question Can’t we do it using stack Was My logic Correct

@yashratnani6 your code is correct i think but you have handle test cases like the 3rd in the sample test case.
because it is possible that when you are done with that loop but any subsequence may pass some more conditions for that.
like in your code for the third test case there can be one more comination and you are just missing that. thats why your code is giving wrong for that.
try to think about that.
Happy Learning!!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.