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