InterviewBit Academy is now Scaler!
Learn Tech Skills from Scratch @ Scaler EDGE

Redundant Braces

Given a string A denoting an expression. It contains the following operators ’+’, ‘-‘, ‘*’, ‘/’.

Chech whether A has redundant braces or not.

Return 1 if A has redundant braces, else return 0.

Note: A will be always a valid expression.

Input Format

The only argument given is string A.

Output Format

Return 1 if string has redundant braces, else return 0.

For Example

Input 1:
    A = "((a + b))"
Output 1:
    Explanation 1:
        ((a + b)) has redundant braces so answer will be 1.

Input 2:
    A = "(a + (a + b))"
Output 2:
    Explanation 2:
        (a + (a + b)) doesn't have have any redundant braces so answer will be 0.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Redundant Braces on Interview Code Editor
Sign Up
to access hints and editorial solutions for Redundant Braces
Asked In:


Click here to start solving coding interview questions