Brackets all over

not able to understand the question even after reading the editorial

You are not able to understand question or solution ?

If u are not able to understand problem
You are given an input string s, which will only contain open or close brackets.

For example: s=((( contains only opening and s=)) contains only closing.
You have to form a+s+b of size n, where a and b are any strings chosen by you and s is the given input string.

Now, the string a and b must be chosen such that string a+s+b, follows 2 properties:
i) At any index, number of opening brackets should be greater than closing brackets.
ii) No. of opening and closing brackets should be equal.

Now consider the given sample input:

4 2
((
here n =4 , string length = 2 and string s = β€œ((”.

There is only one possible way to form a+s+b, with above two properties and with size = n.
i.e. take a = β€œβ€ , b = β€œ))”

a+s+b equals = β€œβ€+ β€œ((” +"))"
Final output string = β€œ(())”
The new string β€œ(())” have above two properties.

Hence output will be 1, as there is only one way possible.

@Kartikkhariwal1
not able to figure out soln also ?? :frowning:

Refer to this

@Kartikkhariwal1
he just wrote the editorial in explaination

which i already read and not able to understand :frowning:

I havent done this question before
Will go through it tomorrow
Till then drop the things u are not able to understand here :slight_smile:
Will reply u tomorrow on it