3
// we will assign each house to its closest heater in position(by taking the4
// minimum of the distance between the two closest heaters to the house) and5
// then store the maximum of these differences(since we want to have the same7
int findRadius(vector<int> &houses, vector<int> &heaters) {8
sort(heaters.begin(), heaters.end());10
for (int house : houses) {11
// finding the smallest heater whose position is not greater than13
int index = lower_bound(heaters.begin(), heaters.end(), house) - heaters.begin();14
if (index == heaters.size()) {17
// the two closest positions to house will be heaters[index] and19
int leftDiff = (index - 1 >= 0) ? abs(house - heaters[index - 1]) : INT_MAX;20
int rightDiff = abs(house - heaters[index]);21
radius = max(radius, min(leftDiff, rightDiff));