Skip to content

Commit c606098

Browse files
authored
Update leetcode485最大连续1的个数.md
1 parent 107732a commit c606098

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

animation-simulation/数组篇/leetcode485最大连续1的个数.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class Solution {
6666

6767
好啦,下面我们直接看代码吧。
6868

69+
Java Code:
70+
6971
```java
7072
class Solution {
7173
public int findMaxConsecutiveOnes(int[] nums) {
@@ -88,3 +90,20 @@ class Solution {
8890
}
8991
```
9092

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

Comments
 (0)