add new solutions
This commit is contained in:
parent
9a10695e8c
commit
ca24d0a56a
30 changed files with 697 additions and 16 deletions
18
solutions/4/q485/solution.go
Normal file
18
solutions/4/q485/solution.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package q485
|
||||
|
||||
func findMaxConsecutiveOnes(nums []int) int {
|
||||
maxNum := 0
|
||||
cur := 0
|
||||
|
||||
for _, n := range nums {
|
||||
if n == 1 {
|
||||
cur++
|
||||
} else {
|
||||
maxNum = max(maxNum, cur)
|
||||
cur = 0
|
||||
}
|
||||
}
|
||||
return max(maxNum, cur)
|
||||
}
|
||||
|
||||
var _ = findMaxConsecutiveOnes
|
||||
Loading…
Add table
Add a link
Reference in a new issue