Heaters for Every Integer House
Updated
Problem statement
A house stands at every integer position from 1 through n. The heaters are at the integer positions in heaters. All heaters use the same nonnegative radius and cover houses at distance at most that radius. Return the minimum radius that covers every house, formatted with exactly nine digits after the decimal point.
Function
minimumRadius(n: int, heaters: int[]) → StringExamples
Example 1
n = 5heaters = [2,4]return = "1.000000000"Every integer house is within one unit of a heater.
Example 2
n = 6heaters = [1,6]return = "2.000000000"Houses 3 and 4 are two units from their nearest heater; a real midpoint is not a house.
Constraints
- For this exercise, assume 1 <= n <= 10^9, 1 <= heaters.length <= 200000, and every heater lies in [1,n]. Duplicate heaters are allowed.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Find Minimum TimeAlphaSense · OA
- Subscription and Usage-Based Billing CalculatorStripe · OAStripe interview questions
- Find Minimum TimeBlackRock · OABlackRock interview questions
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Count Proper Prefix MatchesAT&T · OAAT&T interview questions
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Find Sum of BeautiesAmazon · OA
- Choose ContainersIMC Trading · OAIMC Trading interview questions
- Minimize Maximum Group DifferenceDRW · OADRW interview questions
- Maximum Riders in CarUber · OAUber interview questions