fork download
  1. def findMaxConsecutiveOnes(nums):
  2. max_count=float("-inf")
  3. idx=0
  4. # while(idx<len(nums)):
  5. # count=0
  6. # while(idx<len(nums) and nums[idx]==1):
  7. # count+=1
  8. # idx+=1
  9. # if(count>max_count):
  10. # max_count=count
  11. # idx+=1
  12. # return max_count
  13. count=0
  14. for i in nums:
  15. if(i==1):
  16. count+=1
  17. else:
  18. max_count=max(max_count,count)
  19. count=0
  20. max_count=max(count,max_count)
  21. return max_count
  22. if(__name__=="__main__"):
  23. arr=list(map(int,input().split()))
  24. print(findMaxConsecutiveOnes(arr))
  25.  
Success #stdin #stdout 0.02s 9240KB
stdin
1 1 1 1 0 1 1 1 1 1
stdout
5