Algorithm · Amazon · Medium
Requirements You are given a set of equations, each written as a / b = value, relating variables to one another through known ratios. Then you are given a list of queries of the form x / y. For each query, return the value of the ratio. When the ratio cannot be determined from the given equations, return -1.0 for that query. Before you start writing code, be prepared to justify why a graph traversal such as BFS or DFS is the appropriate technique for this problem. Examples…