deque의 pop(), popleft()
속도 >> list의 pop(), pop(0)
속도
3772ms : list의
pop(), pop(0)
for _ in range(int(input())):
p = list(input())
n = int(input())
arr = input()[1:-1].split(",")
if arr == ['']:
arr = []
rcount = 0
for command in p:
if command == "R":
rcount += 1
elif command == "D":
if not arr:
print("error")
break
if rcount %2 == 0:
arr.pop(0)
else:
arr.pop()
else:
if rcount % 2 == 1:
arr = arr[::-1]
print("["+",".join(arr)+"]")
236ms : deque의
pop(), popleft()
from collections import deque
for _ in range(int(input())):
p = list(input())
n = int(input())
arr = deque(input()[1:-1].split(","))
if arr == deque(['']):
arr = deque([])
rcount = 0
for command in p:
if command == "R":
rcount += 1
elif command == "D":
if not arr:
print("error")
break
if rcount %2 == 0:
arr.popleft()
else:
arr.pop()
else:
if rcount % 2 == 1:
arr = list(arr)[::-1]
print("["+",".join(arr)+"]")