0 day streak
Anonymous · shared experience1 Oct 2025 · 5 views

Yahoo: Convert between units through known ratios

Interview question #Yahoo SDE 3 / Senior DSA / coding

Problem. You are given conversion facts such as feet to inches and inches to centimetres. Answer queries that convert a value from one unit to another, even when there is no direct rule between them.

Approach discussed. Treat each unit as a node and each conversion as a weighted edge, with the reverse edge holding the inverse ratio. For a query, run BFS (or DFS) from the source unit and multiply ratios along the path. Return a not-found answer if the target is unreachable.

Context. Asked as the coding part of a first round for a senior role, after resume and project questions.

0 comments

Comments 0

No comments yet. Ask the author something, or add what happened in your own round.