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()) cubes = deque(map(int, input().split())) last = float('inf') possible = True while cubes: if cubes[0] >= cubes[-1] and cubes[0] <= last: last = cubes.popleft() elif cubes[-1] >= cubes[0] and cubes[-1] <= last: last = cubes.pop() else: possible = False break print("Yes" if possible 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 →