class Solution:
def findRadius(self, houses: List[int], heaters: List[int]) -> int:
houses.sort()
heaters.sort()
L=0
i,j=0,0
while i<len(houses):
if houses[i]<=heaters[j]:
if j==0:
L=max(heaters[j]-houses[i],L)
else:
L=max(L,min(heaters[j]-houses[i],-heaters[j-1]+houses[i]))
else:
if j+1==len(heaters):
L=max(L,-heaters[j]+houses[i])
else:
j+=1
i-=1
# print(i,houses[i],L)
i+=1
return L
相当于排序