Evaluate Division
Try to solve the Evaluate Division problem.
We'll cover the following
Statement
You are given an array of variable pairs equations
and an array of real numbers, values
, where the equations[i] = [A[i], B[i]]
and values[i]
represent the equation values[i] = A[i] / B[i]
Each A[i]
or B[i]
is a string that represents a single variable.
You are also given some queries, where queries[j] = [C[j], D[j]]
represents the query where you must find the answer for C[j] / D[j]
.
Return the answers to all queries. If any single answer cannot be determined, return .
Note: The input is always valid. You may assume that evaluating the queries will not result in division by zero and that there is no contradiction.
Constraints:
-
equations.length
-
equations[i].length
-
A[i].length
,B[i].length
-
values.length
equations.length
-
values[i]
-
queries.length
-
queries[i].length
-
C[j].length
,D[j].length
-
A[i], B[i], C[j], D[j]
consist of lower case English letters and digits.
Examples
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy