You have a list of equations. In each equation you have two operand and one conditional operator. Return False if there exist any contrast in the equation of the list otherwise True.
Input:
["a>b", "b>a"]
["a>b", "b<a", "b>c", "c>a"]
["a>b", "b<a", "d>c"]
["Dog>Cat", "Elephant>Dog", "Cat>Elephant"]
Output:
False
False
True
FalseConstraint:
0<=len(list)<=10^5
1<=operand<=20
Operator: "<", ">"I described an way to solve the equation using hashmap. Got an idea to move with topological sort but couldn't get any point of view from where i should start. After that i got stucked and I couldn't move ahead with any other scope.
Can someone please help me to find out the way to solve?