+ 1
Balanced parentheses
https://code.sololearn.com/cHHlx7KjMQHr/?ref=app Why does the last testcase fail ?
5 Antworten
+ 11
Snehil Pandey ,
your comment could be misunderstood.
')(a+b)('
this string contains the same nunber of opening and closing parenthesis, but it is not what is called *ballanced*.
this is ballanced: '()'
thus is not ballanced: ')('
+ 4
Think of case like : )(a+b)(
+ 1
Jayakrishna🇮🇳 is right
There should be same number of opening as well as closing parenthesis
+ 1
Jayakrishna🇮🇳 https://code.sololearn.com/c9bm1dMfT187/?ref=app
This does not work either.
+ 1
Sanjay Kamath
Your approach finding Number of '(' is equal to Number of ')' . But you should also consider the order.
See my example: )(a+b)(
It has 2 '(' and 2 ')' but those are not in proper way.. You need to rethink about your logic. Some changes needed..
Today only I discussed about same task and what is it how to do in another this thread. Have a look. You may get idea how to correct your code..
Hope it helps..
https://www.sololearn.com/discuss/3094127/?ref=app