본문 바로가기
Beakjoon&프로그래머스/파이썬

[백준/파이썬] 11007번 Inverse Move-to-Front Transform

by 현장 2024. 1. 25.

-Code

for _ in range(int(input())):
    n = int(input())
    nums = list(map(int, input().split()))
    alpa = list("abcdefghijklmnopqrstuvwxyz")
    res = []

    for num in nums:
        temp = alpa.pop(num)
        alpa.insert(0, temp)
        res.append(temp)

    print(*res, sep="")