what is wrong with my solution? it matches which solution which are ac. CodeChef: Practical coding for everyone
The problem I believe is with these lines:
if(s[i]=='(')
{balance= balance++;}
if(s[i]==')')
{balance= balance--;}
When you are incrementing or decrementing a variable, you should just use:
balance++;
balance--;
2 Likes
You cannot rely on a statement:
x = x++;
or
x = x--;
because it is undefined in C++, check it here:
1 Like
Your solution is not working for example from problem statement…
you told me what the problem was but why it is a problem in my solution. can you please help.
simply because incrementing or decrementing doesnt work like balance = balance++;
balance++ is the equivalent of balance = balance + 1, another type is balance += 1;
4 Likes
okay this is very interesting discussion topic…