# [1437\. Check If All 1's Are at Least Length K Places Away](https://leetcode.com/problems/check-if-all-1s-are-at-least-length-k-places-away/) :::spoiler Solution ```cpp= class Solution { public: bool kLengthApart(vector<int>& nums, int k) { int cnt = k; for (int num : nums) { if (num == 1) { if (cnt < k) { return false; } cnt = 0; } else { ++cnt; } } return true; } }; ``` - T: $O(n)$ - S: $O(1)$ :::