题目: 最大连续1的个数
nums=[0,1,0,1,1]
#!/usr/bin/env python
def findMaxConsecutiveOnes(nums):
count = max_count = 0
for num in nums:
if num == 1:
# Increment the count of 1's by one.
count += 1
else:
# Find the maximum till now.
if count > max_count:
max_count = count
# Reset count of 1.
count = 0
return max_count
nums = [1,0,1,1,0]
result = findMaxConsecutiveOnes(nums)
print result