This commit is contained in:
2025-11-17 17:45:06 +08:00
parent f5ce056f2d
commit 2971e19529
4 changed files with 66 additions and 0 deletions

26
25/11/1437.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <vector>
bool kLengthApart(std::vector<int> &nums, int k) {
int count = 0;
bool start = false;
for (int i = 0; i < nums.size(); ++i) {
if (!start) {
if (nums[i] == 1) {
start = true;
}
continue;
}
if (nums[i] == 0) {
count++;
}
if (nums[i] == 1) {
if (count < k) {
return false;
}
count = 0;
}
}
return true;
}