Skip to content

Latest commit

 

History

History
9 lines (9 loc) · 507 Bytes

File metadata and controls

9 lines (9 loc) · 507 Bytes
  • Type: Graph (dfs)
  • Approach:
    • We know the equations and corresponding values so that we can build a directed graph to store the division value of two number.
    • As for a given unknown equation, we can use dfs to search the equation exists or not.
    • The dfs is bottom-up method and if the division value of two number exists, we return the value, otherwise, we return -1.
  • Complexity:
    • Time: O(V+E)
    • Space: O(n)