Similar expressions
Submissions: 6597   Accuracy:

18.72%

  Difficulty: Hard   Marks: 8

Given two expressions in the form of strings. The task is to compare them and check if they are similar. Expressions consist of lowercase alphabets, '+', '-' and  '( )'.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains two lines. And each line contains an expression.

Output
For each test case, print in a new line "YES"  if the expressions are similar else print "NO".

Constraints:
1<=T<=100
3<=|Expression length|<=100

Example:
Input:
2
-(a+b+c)
-a-b-c

a-b-(c-d)
a-b-c-d

Output:
YES
NO

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Arun Tyagi
Author: arun03


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.