pls explain the question and input in it how to approach it??
BRACKETS ALL OVER -doubts
Hey!
Let me explain the sample input step by step
input:
4 2
((
here n=4, m=2 and s=((
Now here s is the given string that we are talking about, m is the size of s (which is 2 in this case), we have to form a new string whose size is given to us- n(4 in this case)
Now, talking about the new string, we have to form it by appending a string a before it and by appending a string b after string s (This is what a+s+b means).
Now in our sample test case we are given n=4, m=2, s=((
we have to form a string of length 4, now that can only be (()), because we have to balance the brackets, we can NOT form a string like: ((() or ())(
therefore to form (()) we have one option a=""{i.e. a blank string} and b="))" {string with 2 closing brackets}.
Try solving this question using DP
ok i understand the input and output what is the approach i cannot getting it have to work on it thanks
Try solving it using dynamic programming
this was given in question tag any other way of solving it other thAN DP some simpler approach/method??
Not sure whether using any simpler method will help you pass all the test cases or not. Try doing it using DP, once you’ve seen the DP videos.
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.