nov cookoff 2014 brackets solution problem



what is wrong with my solution? it matches which solution which are ac.


The problem I believe is with these lines:

{balance= balance++;}
{balance= balance--;}

When you are incrementing or decrementing a variable, you should just use:



You cannot rely on a statement:

x = x++;


x = x--;

because it is undefined in C++, check it here:


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;


I found this -

in C it’s undefined behavior


okay this is very interesting discussion topic…