You are viewing a single comment's thread. Return to all comments →
num_test_cases = int(input()) for _ in range(num_test_cases): _ = int(input()) list_blocks = deque(map(int, input().split(' '))) vertical_pile = [] while len(list_blocks) > 0: if list_blocks[-1] > list_blocks[0]: block_removed = list_blocks.pop() else: block_removed = list_blocks.popleft() vertical_pile.append(block_removed) if all(vertical_pile[i] >= vertical_pile[i+1] for i in range(len(vertical_pile)-1)): print("Yes") else: print("No")
Seems like cookies are disabled on this browser, please enable them to open this website
Piling Up!
You are viewing a single comment's thread. Return to all comments →