You are viewing a single comment's thread. Return to all comments →
Solution using deques, the splicing solutions on here are interesting but unfriendly to read
from collections import deque for _ in range(int(input())): size = int(input()) blocks = deque(map(int,input().split())) head = float('inf') win = True while(len(blocks) > 1 and win): left, right = blocks[0], blocks[-1] if left <= head and right <= head: if left >= right: head = blocks.popleft() else: head = blocks.pop() else: win = False print("Yes") if win and blocks[0] <= head else print("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 →
Solution using deques, the splicing solutions on here are interesting but unfriendly to read