# Redundant Bracket

Given a string of balanced expression, find if it contains a redundant parenthesis or not. A set of parentheses is redundant if the same sub-expression is surrounded by unnecessary or multiple brackets. Print "Yes" if redundant else "No".

**Input:**

The first line of input contains an integer **T** denoting the number of test cases. The next line **T** contains an expression. The expression contains all characters and **^, *, /, +, -**.

**Output:**

For each test case, in a new line, print YES or NO if the expression is redundant or not.

**Examples:**

Input:
T = 1
((a+b))
Output:
YES
(a+b) is surrounded by extra (), which is of no need.
Input:
T = 1
(a+(a+b))
Output:
NO
here there is no extra bracket.

Stack ApproachWe will traverse from left to right and perform the following operations.

then push that into stack otherwise we check for other probabilities as:')'without any other any operator (+, -, /, *) in between them then it is a possible case of redundant brackets:'('then it is a condition of the redundant bracket.')'Example:Pseudo Code:Time Complexity for above approach is: O(n)

Space Complexity for above approach is: O(n)

C++ Implementation:Output2) ImplementationInstead of using the stack to check redundancy, we make two variables to check the number of operators and the number of brackets and check for the condition if some character is present without any operators.

Pseudo Code:C++ Implementation:Output