Input: binary number = 101010101111 k = 4 Output: yes Explanation: at the last 4 index there exists 4 consecutive 1's Input: binary number = 11100000 k = 5 Output: no Explanation: There is a maximum of 3 consecutive 1's in the given binary.
Approach: create a new line with k 1 . Using the if condition, check if s is new. In python, if new in s: checks if any existence exists, if new in s, so it returns true, if there is, then returns false.
Below is the implementation of the above approach in Python: