My issue
the code is executed but it showing as partially correct
My code
def max_people_in_towers(T, test_cases):
for i in range(T):
N = test_cases[i][0]
S = test_cases[i][1]
count = 0
if S[:2] == "00":
count += 1
S = "1" + S[1:]
if S[-2:] == "00":
count += 1
S = S[:-1] + "1"
i = 1
while i < len(S) - 1:
if S[i - 1] == "0" and S[i] == "0" and S[i + 1] == "0":
S = S[:i] + "1" + S[i + 1:]
count += 1
i += 2
else:
i += 1
print(count)
# Input
T = int(input())
test_cases = []
for _ in range(T):
N = int(input())
S = input().strip()
test_cases.append((N, S))
# Output
max_people_in_towers(T, test_cases)
Learning course: Kalasalingam Academy of Research and Education
Problem Link: CodeChef: Practical coding for everyone