Skip to content

feat(ml): leetcode485最大连续1的个数 添加 Python3 Code #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
```