Skip to content

Latest commit

 

History

History
executable file
·
17 lines (9 loc) · 915 Bytes

475.md

File metadata and controls

executable file
·
17 lines (9 loc) · 915 Bytes

475. Heaters

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.

we have heaters' positions and houses positions, it seems binary searching? let me try.

Assume the radius are houses.back() - houses.start, and the minimum radius is 1, and if the middle of the answer can satisfy the answer we will go through the minimum answer other wise we shall go to the middle and the back one.

oh, I almost think I am wrong!!! we need to sort them before...because they are not sorted given.

AC!!