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