My issue
the output is correct still it’s wrong answer what cases i have failed
My code
# cook your dish here
t=int(input())
for i in range(t):
l=str(input())
j=0
l1=[]
for i in range(len(l)):
l1.append(l[i])
while j<(len(l1)-1):
if l1[j+1]=="m" and l1[j]=="s":
l1[j]=""
j=j+1
j=j+1
k=0
while k<(len(l1)-1):
if l1[k-1]!="" and l1[k]=="m" and l1[k+1]=="s":
l1[k+1]=""
k+=1
k+=1
if l1.count("s")>l1.count("m"):
print("snakes")
elif l1.count("s")<l1.count("m"):
print("mongooses")
else:
print("tie")
Learning course: Greedy Algorithms
Problem Link: Snakes, Mongooses and the Ultimate Election Practice Problem in Greedy Algorithms - CodeChef