Just traverse houses array from left to right and greedily pickup the closest heater.

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