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/1437.java
Normal file
15
25/11/1437.java
Normal file
@@ -0,0 +1,15 @@
|
||||
class Solution {
|
||||
public boolean kLengthApart(int[] nums, int k) {
|
||||
int last = -k - 1;
|
||||
for (int i = 0; i < nums.length; i++) {
|
||||
if (nums[i] != 1) {
|
||||
continue;
|
||||
}
|
||||
if (i - last <= k) {
|
||||
return false;
|
||||
}
|
||||
last = i;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user