Check two bracket expressions

Given two strings A and B. Each string represents an expression consisting of lowercase english alphabets, ’+’,
’-‘ and ’()’.
The task is to compare them and check if they are similar. If they are similar return 1 else return 0.

Note: It may be assumed that there are at most 26 operands from ‘a’ to ‘z’ and every operand appears only once.

Input Format

The arguments given are string A and String B.

Output Format

Return 1 if they represent the same expression
else return 0.


1 <= length of the each String <= 100

For Example

Input 1:
     A = "-(a+b+c)"
     B = "-a-b-c"
Output 1:

Input 2:
     A = "a-b-(c-d)"
     B = "a-b-c-d"
Output 2:
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 Check two bracket expressions on Interview Code Editor
Sign Up
to access hints and editorial solutions for Check two bracket expressions


Click here to start solving coding interview questions