Here i am trying to generate all paranthesis…
Don’t know where the code is missing…
Could you please help where the code is failing…
Don't know where i am wrong
hi @ashishnnnnn the problem is that you are not backtracking, you appended a bracket to the string, but you did not remove it for the next step.
I have provided an alternative method for appending characters, so that you dont need to manually backtrack. Check it out here https://ide.codingblocks.com/s/324023
Hii…
Please go through the output of this code…
can you explain after printing (())2 2 2 4
How it is printing 1 1 2 2 (()
Acoording to me it should 1 1 2 2 ()
Please explain this
This is the code…
@ashishnnnnn the reason as i explained above is that you are not backtracking, go through the changes I made in your code you’ll get it
Can you show me… what backtracking steps i could add here in my code… if i am using s.push_back()…
@ashishnnnnn after you do s.push_back()
and do the recursive call
remove the character you added from the string
you can use the pop_back function
Got this…
This will work…