File tree 1 file changed +3
-2
lines changed
scripts/algorithms/H/Heaters
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change
1
+ // Runtime: 62 ms (Top 96.61%) | Memory: 25.4 MB (Top 58.20%)
1
2
class Solution {
2
3
public:
3
4
// we will assign each house to its closest heater in position(by taking the minimum
4
- // of the distance between the two closest heaters to the house) and then store the maximum
5
+ // of the distance between the two closest heaters to the house) and then store the maximum
5
6
// of these differences(since we want to have the same standard radius)
6
7
int findRadius (vector<int >& houses, vector<int >& heaters) {
7
8
sort (heaters.begin (),heaters.end ());
@@ -13,7 +14,7 @@ class Solution {
13
14
if (index ==heaters.size ()){
14
15
index --;
15
16
}
16
- // the two closest positions to house will be heaters[index] and
17
+ // the two closest positions to house will be heaters[index] and
17
18
// heaters[index-1]
18
19
int leftDiff=(index -1 >=0 )?abs (house-heaters[index -1 ]):INT_MAX;
19
20
int rightDiff=abs (house-heaters[index ]);
You can’t perform that action at this time.
0 commit comments