Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://leetcode.com/problems/max-consecutive-ones/submissions/
- def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
- prev_count = 0
- count = 0
- for num in nums:
- if num ==0:
- count = max(count, prev_count)
- prev_count = count
- count = 0
- if num ==1:
- count +=1
- return max(count, prev_count)
Add Comment
Please, Sign In to add comment