[quote=“dashing123, post:61, topic:277”]
Can anybody tell me why my code gets failed?
My code is IN Python…
(CodeChef: Practical coding for everyone)
https://www.codechef.com/viewsolution/35770659
i regret coming to this problem
anyone ? i need some help
try:
for _ in range(int(input())):
k = int(input())
memory = list(input())
rnge = []
status = “nott”
for mm in range(k):
rnge.append(str(mm))
if len(memory) == 1:
if memory[0] == “?”:
print(0)
continue
elif memory[0] != “?” and memory[0] < str(k):
print(memory[0])
else:
print(“NO”)
elif len(memory) == 2:
a = memory[0]
b = memory[1]
if a == b and a == "?" and k >= 2:
print("01")
if a == b and a == "?" and k < 2:
print("NO")
elif a == b and a != "?": # yada ek case or Bana ga
print("NO")
elif a != b and a != "?" and b != "?" and int(a) < k and int(b) < k:
print("".join(memory))
else:
cc = rnge[::]
if a != "?":
cc.remove(memory[0])
if len(cc) == 0:
print("NO")
status = "yesss"
memory[1] = min(cc)
print("".join(memory))
if b != "?":
cc.remove(memory[1])
if len(cc) == 0:
print("NO")
status = "yesss"
memory[0] = min(cc)
print("".join(memory))
else:
for i in range(len(memory)):
a = i
b = i - 1
c = i + 1
if i == 0:
b = len(memory) - 1
if a == len(memory) - 1:
c = 0
if memory[i] != "?":
if memory[a] == memory[b] or memory[a] == memory[c]:
print("NO")
status = "yesss"
break
continue
if memory[0] != "?" and memory[-1] != "?" and memory[0] == memory[-1]:
print("NO")
status = "yesss"
break
cc = rnge[::]
if memory[b] != "?":
cc.remove(memory[b])
if memory[c] != "?" and memory[c] != memory[b]:
cc.remove(memory[c])
if len(cc) == 0:
print("NO")
status = "yesss"
memory[i] = min(cc)
if status != "yesss":
print("".join(memory))
except:
pass
Please anyone can tell me where i am wrong …Answer in Python
it failed here
2
0??
shouldve given 010
instead said no