Skip to content

Commit b24a58b

Browse files
committed
Runtime: 766 ms (Top 22.98%) | Memory: 17.7 MB (Top 39.36%)
1 parent 1519cb9 commit b24a58b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed
+12-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1+
# Runtime: 766 ms (Top 22.98%) | Memory: 17.7 MB (Top 39.36%)
12
class Solution:
23
def findRadius(self, houses: List[int], heaters: List[int]) -> int:
34
"""
4-
5+
56
"""
6-
7-
7+
88
houses.sort()
99
heaters.sort()
10-
11-
10+
1211
max_radius = -inf
13-
14-
for house in houses:
12+
13+
for house in houses:
1514
i = bisect_left(heaters, house)
16-
15+
1716
if i == len(heaters):
1817
max_radius = max(max_radius, house - heaters[-1])
19-
elif i == 0:
20-
max_radius = max(max_radius, heaters[i] - house)
18+
elif i == 0:
19+
max_radius = max(max_radius, heaters[i] - house)
2120
else:
2221
curr = heaters[i]
2322
prev = heaters[i-1]
2423
max_radius = max(max_radius,min(abs(house - curr), abs(house-prev)))
25-
24+
2625
return max_radius
27-
28-
# O(NLOGN)
26+
27+
# O(NLOGN)

0 commit comments

Comments
 (0)