```
public class Solution {
public int findRadius(int[] houses, int[] heaters) {
Arrays.sort(houses);
Arrays.sort(heaters);
int local=0;
int max=0;
int pin=0;
for(int i=0;i<houses.length;i++)
{
while(houses[i]>=heaters[pin]&&pin<heaters.length-1)
{pin++;}
if(pin>=1)
local=Math.min(Math.abs(heaters[pin]-houses[i]),Math.abs(houses[i]-heaters[pin-1]));
else
local=Math.abs(heaters[pin]-houses[i]);
if(local>max)
max=local;
}
return max;
}
}
```