Evaluate Division
Medium · Phone screen · Onsite · Full-time
Interesting graph question from my Stripe onsite. Given equations like a/b = 2.0 and b/c = 3.0, answer queries like a/c. I modeled it as a weighted directed graph and used BFS to find paths between query variables, multiplying edge weights along the way. The interviewer asked about handling contradictory equations, like if two paths between the same nodes give different products, and how I'd detect that. We also discussed union-find as an alternative approach.
