Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding
Ninjas X Naukri.com

Problem of the day

Given a string ‘S’ comprising of some brackets. You need to print the number of every bracket.

```
If S = (pq)()
Then the output will be 1 1 2 2. First pair of opening and closing brackets will get the same number and so does the 2nd pair.
```

Detailed explanation

```
1 <= T <= 50
1 <= |S| <= 10^5
Where ‘|S|’ is the length of a particular string.
Time Limit: 1 Sec
```

```
2
ab(cd)(e)
(zyz)
```

```
1 1 2 2
1 1
```

```
Test Case 1: In the given string, there are two pairs of brackets and the order is 1 1 2 2.
Test Case 2: There is only one pair of brackets. So the number of brackets is 1 1.
```

```
2
(())()
a(b(pq)(t))
```

```
1 2 2 1 3 3
1 2 2 3 3 1
```

```
Test Case 1: In the given string, there are three pairs of brackets and the order is 1 2 2 1 3 3.
Test Case 2: In the given string, there are three pairs of brackets and the order is 1 2 2 3 3 1.
```