diff --git "a/animation-simulation/\346\225\260\347\273\204\347\257\207/leetcode485\346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260.md" "b/animation-simulation/\346\225\260\347\273\204\347\257\207/leetcode485\346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260.md" index 1212710..6157b54 100644 --- "a/animation-simulation/\346\225\260\347\273\204\347\257\207/leetcode485\346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260.md" +++ "b/animation-simulation/\346\225\260\347\273\204\347\257\207/leetcode485\346\234\200\345\244\247\350\277\236\347\273\2551\347\232\204\344\270\252\346\225\260.md" @@ -66,6 +66,8 @@ class Solution { 好啦,下面我们直接看代码吧。 +Java Code: + ```java class Solution { public int findMaxConsecutiveOnes(int[] nums) { @@ -88,3 +90,20 @@ class Solution { } ``` +Python3 Code: + + +```py +class Solution: + def findMaxConsecutiveOnes(self, nums: List[int]) -> int: + ans = i = t = 0 + for j in range(len(nums)): + if nums[j] == 1: + t += 1 + ans = max(ans, t) + else: + i = j + 1 + t = 0 + return ans +``` +