```
public int findRadius(int[] houses, int[] heaters) {
Arrays.sort(houses);
Arrays.sort(heaters);
int res = 0;
int ht = 0;
int nh = heaters.length;
for (int i = 0; i < houses.length; i ++) {
int d = Math.abs(heaters[ht] - houses[i]);
while (ht + 1 < nh && Math.abs(heaters[ht+1] - houses[i]) <= d) {
ht ++;
d = Math.abs(heaters[ht] - houses[i]);
}
res = Math.max(res, d);
}
return res;
}
```