All Problems

Problem title

Difficulty

Avg time to solve

Search In A Row Wise And Column Wise Sorted Matrix

Moderate

15 mins

Complete String

Hard

40 mins

Shopping Options

Easy

--

Replace Spaces

Easy

15 mins

BST queries

Easy

10 mins

Count Distinct Substrings

Moderate

10 mins

Redundant Brackets

Easy

15 mins

Fahrenheit to Celsius

Easy

15 mins

House Robber II

Moderate

15 mins

Distinct Subsequences

Moderate

10 mins

Problem

Submissions

21

Avg. time to solve

15 min

Success Rate

85%

Problem Statement

```
((a+b)) has a pair of redundant brackets. The pair of brackets on the first and last index is needless.
While (a + (b*c)) does not have any pair of redundant brackets.
```

```
The first line contains a single integer βTβ denoting the number of test cases. The test cases follow.
The first line of each test case contains a string denoting the expression.
```

```
For each test case, return βYesβ if the given expression contains at least one pair of redundant brackets, else return βNoβ.
```

```
You donβt need to print anything; It has already been taken care of. Just implement the given function.
```

```
1 <= T <= 50
3 <= |S| <= 10^4
Time Limit: 1 sec
```

```
2
(a+b)
(a+c*b)+(c))
```

```
No
Yes
```

```
In the first test case, there are no redundant brackets. Hence, the output is βNoβ.
In the second test case, the brackets around the alphabet βcβ( index 8 and index 10) are redundant. Hence the output is βYesβ.
```

```
2
(a*b+(c/d))
((a/b))
```

```
No
Yes
```

```
In the first test case, there are no redundant brackets. Hence, the output is βNoβ.
In the second test case, the brackets around the subexpression β(a+b)β ( index 0 and index 6) are redundant. Hence the output is βYesβ.
```

Java (SE 1.8)

Console

Sample Test Case

Custom Test Case

Download Test Cases

Test Case 1

Test Case 2

Test Case 3

Saving Code...

Full Screen Mode

Change Theme

Solution submission not allowed

Save Code

Reset Code