From 5763f68b1c0b0c748fef02af375ff45b22fed9d5 Mon Sep 17 00:00:00 2001 From: Prantik Mukherjee Date: Mon, 12 Jul 2021 12:34:44 +0530 Subject: [PATCH] Added Different Approach --- Arrays/CheckAll1sAreAtLeastKPlacesAway.cpp | 37 ++++++++++++++++------ 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/Arrays/CheckAll1sAreAtLeastKPlacesAway.cpp b/Arrays/CheckAll1sAreAtLeastKPlacesAway.cpp index 81b4968..406fd8d 100644 --- a/Arrays/CheckAll1sAreAtLeastKPlacesAway.cpp +++ b/Arrays/CheckAll1sAreAtLeastKPlacesAway.cpp @@ -1,16 +1,33 @@ -static auto fast=[]{ios_base::sync_with_stdio(false);cin.tie(nullptr);return 0;}(); +// static auto fast=[]{ios_base::sync_with_stdio(false);cin.tie(nullptr);return 0;}(); +// class Solution { +// public: +// bool kLengthApart(vector& nums, int k) { +// int s=0; +// int c=0; +// while(s& nums, int k) { - int s=0; - int c=0; - while(s 0) return false; + // otherwise we either reset or decrease j + else j = nums[i] ? k : j - 1; } return true; } -}; \ No newline at end of file +};