Leetcode 399. Evaluate Division
Given pairwise variable ratios, build a weighted graph (or use union-find with multiplicative weights) where edges represent divisions, and answer each query by finding a path between the two variables and multiplying edge weights along that path; return -1.0 if no path (variable undefined) exists.
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Early September, 2026
Similar to above question. It was worded differently like we have many clusters and given a cluster, we had to traverse through the child clusters and find the cumulative product of the weights and return a list of all the leaf clusters. Input - edge -> [{"canary", 5}, {"stable", 95}] stable -> [{"us_east", 3}, {"us_west", 1}] canary -> [{"us_east", 1}, {vs_col, 1}] Output - Output should be - us_east: edge -> stable -> us_east 0.95 * 0.75 = 0.7125 edge -> canary -> us_east 0.05 * 0.50 = 0.025 total = 0.7375 us_west: 0.95 * 0.25 = 0.2375 vs_col: 0.05 * 0.50 = 0.025 -> =================================================== us_east = 0.7375 us_west = 0.2375 vs_col = 0.025
Early June, 2025
Hello Interview Premium
Your account is free and you can post anonymously if you choose.