[Solution] Dense Bracket Sequence CodeChef Solution | CodeChef Problem Solution 2022
A bracket sequence is called dense if one of the following is true:
- is empty.
- where is dense.
You are given a bracket sequence . What is the minimum number of brackets you must remove to make it dense?
Input Format
- The first line of input will contain a single integer , the number of test cases. The description of the test cases follows.
- The first line of each test case contains one integer , denoting the length of the bracket sequence.
Solution Click Below:- CLICK HERE
- The second line of each test case contains the bracket sequence of length .
Output Format
For each test case, output on a new line the minimum number of brackets you must remove from to make it dense.
No comments:
Post a Comment