Redundant Parantheses


Im getting wrong output for Redundant parantheses can u tell me where am i going wrong?

Hey @apoorv.chauhann in line number 19 make !s.top()==β€˜(β€˜
To
S.top()!=β€˜(β€˜
And it will work :slight_smile:

https://ide.codingblocks.com/s/353073 It still giving wrong output from my input

Instead of making a bool variable, try to solve it using int variable. Here’s my code for reference which will help you https://ide.codingblocks.com/s/353569

(a+(b)) for this input it shows Not redundant but it has duplicate

(a+(b)/c)…for this also Its duplicate but it shows not dupliate

Wait a minute @apoorv.chauhann, the question link you have provided is not opening, might be a glitch. Copy and paste that question here , as it might be something related to +,-,*,/.

@apoorv.chauhann try this one https://ide.codingblocks.com/s/337197 , due to some backend glitch I was unable to find that problem statement. This might help :slight_smile:

Given a string of balanced expression, find if it contains a redundant parenthesis or not. A set of parenthesis are redundant if same sub-expression is surrounded by unnecessary or multiple brackets. Print β€˜Yes’ if redundant else β€˜No’. Note: Expression may contain β€˜+β€˜, β€˜*β€˜, β€˜β€“β€˜ and β€˜/β€˜ operators. Given expression is valid and there are no white spaces present.

I request to modify the code that u sent me for refrence for the above problem statement

It’s almost same @apoorv.chauhann , if you won’t be able to understand anything in this code. You can ask me I’ll surely help you :smiley: