Skip to content

Practice Heaters

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#475
LeetCode Problem

Heaters

Problem Statement

Winter is coming! During the contest, your first job is to design a standard heater with a fixed warm radius to warm all the houses. Every house can be warmed, as long as the house is within the heater's warm radius range. Given the positions of houses and heaters on a horizontal line, return the minimum radius standard of heaters so that those heaters could cover all houses. Notice that all the heaters follow your radius standard, and the warm radius will the same.

Source: Heaters on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
houses = [1,2,3], heaters = [2]
Output
1

# Example 2

Input
houses = [1,2,3,4], heaters = [1,4]
Output
1

# Example 3

Input
houses = [1,5], heaters = [2]
Output
3

Constraints

1 <= houses.length, heaters.length <= 3 * 10^4
1 <= houses[i], heaters[i] <= 10^9

Related LeetCode Problems

Practice more problems similar to Heaters.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.