Equation division evaluator
You are given a list of equations like `["a","b"]` meaning `a / b = value`, plus the parallel list of positive float `values`. For each query `["x","y"]` return the value of `x / y` computed by chaining known ratios, or `-1.0` if it cannot be determined (an unknown variable or a disconnected pair). A query of a variable with itself, if the variable is known, is `1.0`. Round each answer to 5 decimal places.
Implement
evaluate_division(equations: list[list], values: list[float], queries: list[list]) → list[float]Examples
in
[[["a","b"],["b","c"]],[2,3],[["a","c"],["b","a"],["a","e"],["x","x"]]]out[6,0.5,-1,-1]What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 30 min
solution.py
InputExpectedGot
[[["a","b"],["b","c"]],[2,3],[["a","c"],["b","a"],["a","e"],["x","x"]]][6,0.5,-1,-1]not run yetsample