We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 107732a commit c606098Copy full SHA for c606098
animation-simulation/数组篇/leetcode485最大连续1的个数.md
@@ -66,6 +66,8 @@ class Solution {
66
67
好啦,下面我们直接看代码吧。
68
69
+Java Code:
70
+
71
```java
72
class Solution {
73
public int findMaxConsecutiveOnes(int[] nums) {
@@ -88,3 +90,20 @@ class Solution {
88
90
}
89
91
```
92
93
+Python3 Code:
94
95
96
+```py
97
+class Solution:
98
+ def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
99
+ ans = i = t = 0
100
+ for j in range(len(nums)):
101
+ if nums[j] == 1:
102
+ t += 1
103
+ ans = max(ans, t)
104
+ else:
105
+ i = j + 1
106
+ t = 0
107
+ return ans
108
+```
109
0 commit comments