equations[i] = [A, B] and values[i] mean A / B = values[i], where the variables are strings and every value is a positive number. Each query [C, D] asks for C / D.
Return an array with one answer per query. If a query cannot be answered from the equations, its answer is -1.
- A variable that never appears in any equation is unknown, even when the query divides it by itself (
x / x is -1 if x is unknown) - A known variable divided by itself is
1 - The equations are consistent: they never contradict one another
- Think of variables as nodes and equations as weighted edges in both directions
- Compare floating-point answers with a tolerance in your own checks; the tests here do