Skip to content

Instantly share code, notes, and snippets.

@luojiyin1987
Last active August 3, 2017 03:01
Show Gist options
  • Save luojiyin1987/cb9f96e9f588a8991c1a9d4f56725619 to your computer and use it in GitHub Desktop.
Save luojiyin1987/cb9f96e9f588a8991c1a9d4f56725619 to your computer and use it in GitHub Desktop.
Max Consecutive Ones
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