You are given an balanced expression. You have to find if it contains duplicate parentheses or not. A set of parentheses are duplicate if same subexpression is surrounded by multiple parenthesis.
Question not clear?
You need to check if any subexpression is surrounded by parenthesis multiple times.
For example, a+((b)) here b is surrounded by multiple parenthesis, so ans is Duplicate for this case while ans for a + (b) is Not Duplicate.
2
(((a+(b))+(c+d)))
((a+(b))+(c+d))
Sample Output
Duplicate
Not Duplicates
Explanation
For 1st test case : The subexpression “a+(b)” is surrounded by two pairs of brackets.
how here ??? only one parenthesis is there around a+(b)—>(a+(b))
Yes but the whole expression (a+(b))+(c+d) is surrounded by multiple parenthesis.