Evaluate Division
CodingPhone ScreenSoftware EngineerReported Sep, 2025
Examples
Example 1:
Input: equations = [["a","b"],["b","c"]], values = [2.0,4.0], queries = [["a","c"],["c","a"],["a","e"]]
Output: [8.0,0.125,-1.0]
Example 1:
Input: equations = [["a","b"],["b","c"]], values = [2.0,4.0], queries = [["a","c"],["c","a"],["a","e"]]
Output: [8.0,0.125,-1.0]
You are given equations such as A / B = k, represented by equations[i] = [A, B] and values[i] = k.
For each query [C, D], return the value of C / D if it can be determined from the given equations, or -1.0 otherwise.
1 <= equations.length <= 20values.length == equations.length1 <= queries.length <= 20Reported as LeetCode 399 in a software engineer phone screen.