题目:
题解:
class Solution:def findRadius(self, houses: List[int], heaters: List[int]) -> int:ans = 0houses.sort()heaters.sort()j = 0for i, house in enumerate(houses):curDistance = abs(house - heaters[j])while j + 1 < len(heaters) and abs(houses[i] - heaters[j]) >= abs(houses[i] - heaters[j + 1]):j += 1curDistance = min(curDistance, abs(houses[i] - heaters[j]))ans = max(ans, curDistance)return ans