좌우영역에서 검사하는 것으로 투포인터를 이용했습니다.
import sys
input = sys.stdin.readline
for test in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
left, right = 0, n - 1
answer = []
while left <= right:
answer.append(arr[left])
if left == right:
break
answer.append(arr[right])
left += 1
right -= 1
print(*answer)
'practivceAlgorithm > codeforce' 카테고리의 다른 글
[codeforce][Python] #690 C. Unique Number (0) | 2021.12.07 |
---|---|
[codeforce][Python] #690 B. Last Year's Substring (0) | 2021.12.07 |
[Codeforce][Python] #702 F. Equalize the Array (0) | 2021.11.07 |
[Codeforce][Python] #702 D. Permutation Transformation (0) | 2021.11.07 |
[Codeforce][Python] #702 E. Accidental Victory (0) | 2021.11.07 |