You are viewing a single comment's thread. Return to all comments →
from collections import deque t = int(input()) for _ in range(t): l = int(input()) blocks = deque(list(map(int, input().split()))) top = blocks.popleft() if blocks[0]>=blocks[-1] else blocks.pop() while len(blocks)>0: next_block = blocks.popleft() if blocks[0]>=blocks[-1] else blocks.pop() if top >= next_block: top = next_block if len(blocks)>=1: continue else: print('Yes') else: print('No') break
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 →