There are N office cubicles placed in a straight line, each with a bright bulb. Each light bulb can brighten K rooms on either side of it (also the one in which the light bulb itself is), but all the cubicles don't have a bulb. You are given an array A which gives the information about the location of the bulbs. If A[i] is equal to 1, then the cubicle has a light bulb, else if A[i] is 0, then the cubicle doesn't have a bulb. You need to find out whether all the cubicles are bright or not.
Example 1:
Input: N = 4, K = 3
A = {0, 1, 0, 1}
Output: 1
Explaination: The first cubicle can be 
brightened by 2nd cubicle. The third 
cubicle can be brightened by 4th cubicle.
Example 2:
Input: N = 7, K = 2
A = {1, 0, 0, 0, 0, 0, 1}
Output: 0
Explaination: The fourth cubicle cannot be 
brightened in any way.
Your Task:
You do not need to read input or print anything. Your task is to complete the function isBrightened() which takes N, K and A as input parameters and returns 1 if all the cubicles can be brightened. Otherwise, returns 0.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{4}
1 ≤ K ≤ 20
0 ≤ A[i] ≤ 1

Difficulty: EASY
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def isBrightened(self, N, K, A):
        # code here

Solutions:
class Solution:

	def isBrightened(self, N, K, A):
		if K == 0:
			return int(not 0 in A)
		if not 1 in A[-K - 1:]:
			return 0
		while len(A) > K:
			flag = True
			for _ in range(2 * K + 1):
				if A.pop():
					flag = False
					break
				if not A:
					break
			if flag:
				return 0
		return 1


class Solution:

	def isBrightened(self, N, K, A):
		i = 0
		count = 0
		while i < N:
			if A[i] == 1:
				count = K
			elif count == -K:
				return 0
			else:
				count -= 1
			i += 1
		if count < 0:
			return 0
		return 1


class Solution:

	def isBrightened(self, n, k, A):
		prev = 0
		for i in range(n):
			if A[i] == 1:
				if i - k > prev:
					return 0
				prev = i + k + 1
		return 1 if prev >= n else 0


class Solution:

	def isBrightened(self, N, K, A):
		if N == 1 and A[0] == 0:
			return 0
		if N == 1 and A[0] == 1:
			return 1
		prev = 0
		c = 0
		for i in range(N):
			if A[i] == 1:
				if i - K > prev:
					return 0
				prev = i + K + 1
		if prev >= N:
			return 1
		else:
			return 0


class Solution:

	def isBrightened(self, n, k, arr):
		prev = 0
		for i in range(n):
			if arr[i] == 1:
				if prev < i - k:
					return 0
				prev = i + k + 1
		if prev >= n:
			return 1


class Solution:

	def isBrightened(self, N, K, A):
		for (idx, i) in enumerate(A):
			if i == 1:
				for j in range(max(0, idx - K), min(idx + K + 1, len(A))):
					if not A[j] == 1:
						A[j] = 2
		for s in A:
			if s == 0:
				return 0
		return 1


class Solution:

	def isBrightened(self, N, K, A):
		var = 0
		temp = 0
		for el in A:
			if var < 0 and temp > 0:
				var += temp
				temp = 0
			if el == 0:
				var -= 1
			else:
				temp = K
				if var < 0:
					var += K
					if var < 0:
						return 0
					else:
						var = 0
				else:
					var = 0
		if var < 0 and temp > 0:
			var += temp
		return 1 if var >= 0 else 0


class Solution:

	def isBrightened(self, N, K, A):
		for i in range(N):
			if A[i] == 0:
				if i - K >= 0 and i + K <= N:
					x = A[i - K:i + K + 1]
					if 1 not in x:
						return 0
				elif i - K >= 0 and i + K > N:
					x = A[i - K:]
					if 1 not in x:
						return 0
				elif i - K < 0 and i + K <= N:
					x = A[:i + K + 1]
					if 1 not in x:
						return 0
				else:
					x = A[:]
					if 1 not in x:
						return 0
		return 1


class Solution:

	def isBrightened(self, N, K, A):
		st = [i + 1 - K - 1 for i in range(len(A)) if A[i]] + [len(A)]
		end = [1] + [i + 1 + K + 1 for i in range(len(A)) if A[i]]
		return int(all((st[i] < end[i] for i in range(len(st)))))