Can able to write code for minimum number of reversal of brackets to make balanced


plz tell how to write recursive code for this

hello @kingshuk441

u need to check ur given string with all possible string of length n and then conisder that string which gives minimum string.

now to generate n length stirng having { or } .
put { at index i and call for i+1
or
put } at index i and call i+1

base case
if i==n compare genrated string with given string and compute number of swaps.
and update ur answer

how it will check whether configuration is balanced or not
can u provide code for it plz

every thing is already covered in ur course.

for this problem check ur stack playlist

this means first we have to make all configurations by taking both cases and after every time base case gets called then we have to check whether the configuration is balanced(by using the stack technique o(N)) or not and if it is balanced then we have to compare with the input string that what are the reversal required ? is this is the way ?

yeah correct…

means the total time complexity is o(N)+o(2^N)?

yeah complexity will be exponential

Thank you sir
i need one more help sir my one doubt has not been taken for 4 days can you take that one also as your explaination is very easy to understand

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.