题目:
代码:
class Solution {
public:
bool kLengthApart(vector<int>& nums, int k) {
int before=-100000;
for(int i=0;i<nums.size();i++){
if(nums[i]==1){
if(i-before<=k){
return false;
}
else{
before=i;
}
}
}
return true;
}
};