add new solutions

This commit is contained in:
kanna5 2026-01-05 16:48:03 +09:00
parent 9a10695e8c
commit ca24d0a56a
Signed by: kkyy
GPG key ID: 06332F3965E9B0CF
30 changed files with 697 additions and 16 deletions

View file

@ -0,0 +1,22 @@
package q448
func findDisappearedNumbers(nums []int) []int {
n := len(nums)
ret := make([]int, n)
for i := range ret {
ret[i] = i + 1
}
for _, num := range nums {
ret[num-1] = -1
}
p := 0
for i := range ret {
if ret[i] != -1 {
ret[p] = ret[i]
p++
}
}
return ret[:p]
}
var _ = findDisappearedNumbers

View 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