Skip to content

Commit 37ce739

Browse files
committed
added 849 problem
1 parent 1c3a15d commit 37ce739

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

python3/849.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
seats = list(map(int, input().split(',')))
2+
3+
maxi = 0
4+
temp= 0
5+
may_max =0
6+
7+
i=0
8+
if seats[0] == 0:
9+
while seats[i] !=1:
10+
may_max += 1
11+
i +=1
12+
13+
for j in range(i, len(seats)):
14+
if seats[j] == 0:
15+
temp +=1
16+
else:
17+
maxi = max(maxi, temp)
18+
temp = 0
19+
20+
print(max(may_max, temp, (maxi+1)//2))
21+
22+
# There is solution which is simulated to the leetcode
23+
24+
# class Solution:
25+
# def maxDistToClosest(self, seats: List[int]) -> int:
26+
# maxi = 0
27+
# temp = 0
28+
29+
# may_max = 0
30+
# i = 0
31+
# if seats[0] == 0:
32+
# while seats[i] !=1:
33+
# i+=1
34+
# may_max += 1
35+
36+
37+
# for j in range(i, len(seats)):
38+
# if seats[j] == 0:
39+
# temp += 1
40+
# else:
41+
# maxi = max(maxi, temp)
42+
# temp = 0
43+
# return max(temp, may_max, (maxi+1)//2)
44+

0 commit comments

Comments
 (0)