Last active
August 3, 2017 03:01
-
-
Save luojiyin1987/cb9f96e9f588a8991c1a9d4f56725619 to your computer and use it in GitHub Desktop.
Max Consecutive Ones
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func findMaxConsecutiveOnes(nums []int) int { | |
| count :=0 | |
| Max :=0 | |
| for _, i := range nums { | |
| if i== 1 { | |
| count+=1 | |
| if count >Max { | |
| Max = count | |
| } | |
| } else { | |
| count =0 | |
| } | |
| } | |
| return Max | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment