Algorithm · C3.ai · Medium
You are given a collection of equations involving named variables, where each equation states that one variable divided by another equals a known number, written as $$A / B = value$$. You are also given a list of queries. Each query names two variables C and D and asks for the value of $$C / D$$. For every query, compute that quotient from the information in the equations; if the quotient cannot be worked out, the answer for that query is -1.0. A variable that is never…