Evaluate Division
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given equations[i] = [A, B] together with values[i], meaning the variable ratio A / B equals values[i]. Variables are strings, every value is positive, and the equations never contradict each other.
For each queries[j] = [C, D], compute C / D using only the given equations. If the ratio cannot be determined — because C or D never appears in any equation, or they are in unrelated groups of variables — the answer is -1.0. A variable divided by itself is 1.0 **only if** that variable appears in some equation; otherwise it is -1.0.
Return the answers as an array in query order. Answers are compared with an absolute tolerance of 1e-6; do not round.
Examples
Constraints
- 1 <= equations.length <= 60
- values.length == equations.length and 0.0 < values[i] <= 100.0
- 1 <= queries.length <= 60
- Variable names are 1 to 5 lowercase letters or digits; A != B in every equation
- The equations are consistent
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.