Heaters
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Houses and heaters sit at integer positions on a line, given as arrays houses and heaters (both unsorted, duplicates allowed). Every heater warms all positions within distance r of it, and all heaters share the same radius r.
Return the **minimum** integer radius r such that every house is within distance r of at least one heater.
Aim for O((n + m) log m) time, where n and m are the numbers of houses and heaters.
Examples
Constraints
- 1 <= houses.length, heaters.length <= 3 * 10^4
- 1 <= houses[i], heaters[i] <= 10^9
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.