본문 바로가기

알고리즘

[SWEA] 5097. 회전 (Python)

-풀이

T = int(input())

for test_case in range(1, T + 1):
    n, m = map(int, input().split())
    queue = list(map(int, input().split()))
    
    for i in range(m):
        queue.append(queue.pop(0))
    
    print('#{} {}'.format(test_case, queue[0]))

deque 모듈을 import해서도 구현이 가능하다.