Skip to content

#399 - Evaluate Division

MediumGraphs - DFS
Open on LeetCode

You are given equations like a / b = k and queries [c, d]. Return the answer for each query, or -1.0 if the answer cannot be determined. Variables that appear in equations are connected via multiplication/division.

InputOutput
equations = [["a","b"],["b","c"]], values = [2.0,3.0], queries = [["a","c"],["b","a"],["a","e"],["a","a"],["x","x"]][6.0, 0.5, -1.0, 1.0, -1.0]

Released under the MIT License.