TOPIC

Wrong answer (5%) Python

David Ferreira asked 4 months ago


casos = int(input())

for i in range(casos):
    string = input()

    sequencias = [[['7', 'Q', 'J', 'K', 'A'], '']]
    remocao = 0
    nova_sequencia = True

    for j in range(len(string)):
        for k in sequencias:
            if len(k[0]) > 0 and k[0][0] == string[j]:
                k[1] += string[j]
                k[0].pop(0)
                nova_sequencia = False
                break

        if nova_sequencia:
            if string[j] == '7':
                sequencias.append([['Q', 'J', 'K', 'A'], '7'])
            else:
                remocao += 1

        nova_sequencia = True

    for j in sequencias:
        if j[1] != '7QJKA':
            remocao += len(j[1])

    print(remocao)

Não sei aonde está o meu erro. Testei com os inputs do udebug e deu igual, mas continuo levando 5% de erro. Se alguém puder ajudar.

This topic has not been answered yet. Be the first!

Remember not post solutions. Your post may be reviewed by our moderators.