Update leetcode485最大连续1的个数.md

pull/15/head
lucifer 2021-04-26 14:52:03 +08:00 committed by GitHub
parent 107732a6c8
commit c6060983ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 0 deletions

View File

@ -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
```