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