Evaluate Division

In the problem #399 EVALUATE DIVISION why are the test cases giving output "-1" when the queires solution can be found out by reducing the given equations of the form A/B to simpler form by removing the common terms from numerator and denominator?

Eg-
Equations-[["a","b"],["b","c"],["bc","cd"]]
Values-[1.5,2.5,5.0]
Queries - [["a","c"],["c","b"],["bc","cd"],["b","d"]]

Here we already know bc/cd so by default we know the value of b/d and hence the output of last query should be 5.0 instead of -1.0. In cases like these the Graph solution will have to be altered.

Thanks
Shivam

Comments (0)