-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy path485.py
23 lines (22 loc) · 860 Bytes
/
485.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
__________________________________________________________________________________________________
sample 380 ms submission
class Solution:
def findMaxConsecutiveOnes(self, nums):
return max(len(list(g)) if k == 1 else 0 for k, g in itertools.groupby(nums))
__________________________________________________________________________________________________
sample 13116 kb submission
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
ans = 0
temp = 0
for i in nums:
if(i == 1):
temp += 1
else:
if(temp > ans):
ans = temp
temp = 0
if(temp > ans):
ans = temp
return ans
__________________________________________________________________________________________________