Reported September 2026
Applegraph

Unit Conversion Across Independent Families

Reported by candidates from Apple's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Apple OA. Under 2s to a working solution.
Founder's read

Apple's September 2026 OA hands you a unit converter and hopes you reach for the wrong tool. It looks like a string-parsing problem, but it really reduces to a graph with weighted edges, where each rate has a reciprocal going backward. Queries run up to 100000, so the naive approach of searching per query is the trap. If you see this on the assessment, name the pattern fast: weighted union-find or one traversal per component. And if your mind goes blank mid-OA, StealthCoder runs invisibly on your screen and can hand you the solution as a safety net.

The problem

Each row in conversions is [source, target, rate] and means one unit of source equals rate units of target. A relationship may also be traversed backward using its reciprocal. Conversion families may be disconnected.
For every [from, to] query, return the product of rates along a conversion path, formatted with exactly six decimal places. Return UNKNOWN when either name does not appear or no path connects the two units. A known unit converted to itself is 1.000000.

Function
queryUnitConversions(conversions: String[][], queries: String[][]) → String[]

Examples
Example 1
conversions = [["C","F","1.8"],["m","cm","100"]]
queries = [["C","F"],["F","C"],["C","cm"],["m","cm"]]
return = ["1.800000","0.555556","UNKNOWN","100.000000"]
Temperature and length queries work within their own families, while a cross-family query is unknown.
Example 2
conversions = [["a","b","2"],["b","c","3"]]
queries = [["a","c"],["c","a"],["b","b"]]
return = ["6.000000","0.166667","1.000000"]
Path products, reciprocal traversal, and identity queries share one component.

Constraints
0 <= conversions.length, queries.length <= 100000.
Rates are positive decimal strings.
All relationships are mutually consistent, so every path between the same pair has the same product.
Unit names are nonempty and contain no spaces.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: conversions are consistent, so any path between two units gives the same product. That means you only need one path per component. Build an adjacency map with rate forward and 1/rate backward. Then run a DFS or BFS from each unvisited unit, assigning it a value relative to a root (root = 1, neighbor = current * rate). Answer each query as value[from] ratio value[to], valid only if both share a component id. Weighted union-find with path compression does the same thing online. Pitfalls: a unit missing from the map must return UNKNOWN even when from equals to, so check existence before the identity case. Format with exactly six decimals. Don't run a search per query, that's up to 100000 searches on a big graph. If you freeze on the weighted find, StealthCoder is the hedge during the live OA. It reads the problem and gives you working code.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Unit Conversion Across Independent Families cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as evaluate division. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Apple's OA.

Apple reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Unit Conversion Across Independent Families FAQ

What's the trick in the Apple unit conversion OA?+

Treat units as nodes and rates as weighted edges, with the reciprocal going backward. Because all paths agree, label each component once from a root. Then every query is a division of two stored values, as long as both units share a component.

Should I use union-find or DFS here?+

Either works. DFS or BFS labeling is simpler to write correctly: one pass assigns each unit a value relative to its component root. Weighted union-find is neat but easier to get wrong under time pressure with the ratio updates during path compression.

How do I handle the UNKNOWN cases?+

Return UNKNOWN if either unit name never appears in the conversions, or if the two units sit in different components. Check existence first. A unit that isn't in the input returns UNKNOWN even when the query is the same name twice. A known unit to itself is 1.000000.

Any precision or formatting gotchas?+

Rates come in as strings, so parse them as doubles. Output needs exactly six decimal places, like 0.555556, so use a fixed-format call in your language. Computing ratios from root values can drift slightly, but doubles are fine given the consistency guarantee.

How do I prep for this in 48 hours?+

Write the component-labeling solution once from scratch. Practice a similar weighted-graph problem, like evaluating division equations. Test it on disconnected families, a missing unit, and a self-query. If you can explain why one path per component is enough, you've got the core idea.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Apple.

OA at Apple?
Invisible during screen share
Get it