mirror of
https://github.com/lWolvesl/leetcode.git
synced 2026-01-12 18:08:38 +08:00
1437
This commit is contained in:
15
25/11/go/1437.go
Normal file
15
25/11/go/1437.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package C
|
||||
|
||||
func kLengthApart(nums []int, k int) bool {
|
||||
last := -k - 1
|
||||
for i := 0; i < len(nums); i++ {
|
||||
if nums[i] != 1 {
|
||||
continue
|
||||
}
|
||||
if i-last <= k {
|
||||
return false
|
||||
}
|
||||
last = i
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user