[LeetCode] Max Consecutive Ones (Python)
2024. 2. 27. 10:16ㆍ자료구조
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
maximum = 0
temp = 0
for i in range(len(nums)):
if nums[i] == 1:
temp += 1
else:
maximum = max(maximum, temp)
temp = 0
return max(maximum, temp)
'자료구조' 카테고리의 다른 글
[LeetCode] Remove Element (Python) (0) | 2024.02.27 |
---|---|
[LeetCode] Merge Sorted Array (Python) (0) | 2024.02.27 |
[LeetCode] Duplicate Zeros (Python) (0) | 2024.02.27 |
[LeetCode] Squares of a Sorted Array (Python) (0) | 2024.02.27 |
[LeetCode] Find Numbers with Even Number of Digits (Python) (0) | 2024.02.27 |