Brackets All Over

Can you please explain how to approach this problem, also with a sample test caseā€¦

Can you please explain how to approach this problem, also with a sample test caseā€¦

Can you please explain how to approach this problem, also with a sample test caseā€¦

Can you please explain how to approach this problem, also with a sample test caseā€¦

hey @Karanveer in this question you are given a string of length ā€˜mā€™.
and you have to make that string of length n
such that you have two conditons which should be true at every point .
lets take the example of the sample test case only.
4 2
((
in this question you have make this string a valid string .
valid string is the sring in which the number of opening and closing bracket are equal.
in this case if you add even one more opening bracket then you woudnt be able to make this a valid string ,because in that case you need to make a string of size 6 so that it can be a valid.
that is the reason you are only left with the the option of concatenating this string with a="" in the front so that the number of opening bracker doesnā€™t increases .
and to add b with two closing brackets .
which is the only option to make it a valid string .
i hope i have cleared your doubt .
try to do the code on your own .
if you still have any doubt please write here .
Happy Learning !!

Thanks for the beautiful explanation

Can you give me some hint, how to approach this problemā€¦

@Karanveer try to think for sometime if you still not able to think then i will give you the code .
this would let you think for some tricks which you will only be able to define whether you can do the question in this way or not .

hii, i tried but couldnā€™t reach to a solutionā€¦ so please help with this one with a clear explanation of the solutionā€¦

@Karanveer here is the code https://ide.codingblocks.com/s/325920.

Can you please explain the codeā€¦

hello @Karanveer sorry i am replying late there was some notification issue.
have your doubt cleared or the doubt still persists ?

Can you please explain the code. Iā€™ve gone through it but Iā€™m not able to understand how it is working.