We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7d0ae11 commit cbd7d63Copy full SHA for cbd7d63
arrays/849_Maximize_Distance_to_Closest_Person/solution.py
@@ -13,21 +13,18 @@ def max_dist_to_closest(seats: list[int]) -> int:
13
"""
14
length = len(seats)
15
left = None
16
- right = None
17
result = 1
18
19
for index in range(length):
20
if seats[index] == 0:
21
if left is None:
22
left = index
23
- right = index
24
- if (left == 0) or (right == length - 1):
25
- result = max(result, right - left + 1)
+ if (left == 0) or (index == length - 1):
+ result = max(result, index - left + 1)
26
else:
27
- result = max(result, (right - left + 2) // 2)
+ result = max(result, (index - left + 2) // 2)
28
29
30
31
return result
32
33
0 commit comments