Commit b11e07ee by bonnieyan

提交作业

parent 597c7e71
# class Heater:
#
# class Solution(object): def findRadius(self, houses, heaters):
# heaters.sort()
# def find_radius(self, house, heaters): houses.sort()
# radius = 0
# i = 0
# # 哨兵
# su = Solution() heaters = [-1] + heaters + [float('inf')]
# su.find_radius([1, 2, 3, 4], [1, 4]) for house in houses:
while house > heaters[i]:
i = i + 1
current_radius = min(house - heaters[i - 1], heaters[i] - house)
radius = max(radius, current_radius)
return radius
h = Heater()
result = h.findRadius([1, 2, 3, 4, 6], [1, 4])
print(result)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment