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 1c3a15d commit 37ce739Copy full SHA for 37ce739
python3/849.py
@@ -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
43
+# return max(temp, may_max, (maxi+1)//2)
44
0 commit comments