We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUT
from collections import deque
t = int(input())
for _ in range(t):
n=int(input())
blocks=list(map(int,input().split()))
dq = deque(blocks)
current = float('inf')
possible = True
while dq:
if dq[-1] >= dq[0]:
next_block = dq.pop()
else:
next_block = dq.popleft()
if next_block > current:
possible=False
break
current = next_block
print("Yes" if possible else "No")
Cookie support is required to access HackerRank
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 →
# Enter your code here. Read input from STDIN. Print output to STDOUT from collections import deque
t = int(input())
for _ in range(t): n=int(input()) blocks=list(map(int,input().split()))