Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func findMaxConsecutiveOnes(_ nums: [Int]) -> Int {
- var result = 0
- var current = 0
- var r = 0
- while r < nums.count {
- if nums[r] == 1 {
- current += 1
- result = max(current, result)
- } else if nums[r] == 0 {
- current = 0
- }
- r += 1
- }
- return result
- }
- let nums = [1,0,1,1,0,1]
- findMaxConsecutiveOnes(nums)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement