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.
t = int(input())
for _ in range(t):
n = int(input())
ls = list(map(int, input().split()))
k = float('inf')
left, right = 0, n - 1
while left <= right:
if k < max(ls[left], ls[right]):
print("No")
break
if ls[left] > ls[right]:
k = ls[left]
left += 1
else:
k = ls[right]
right -= 1
else:
print("Yes")
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 →
t = int(input()) for _ in range(t): n = int(input()) ls = list(map(int, input().split())) k = float('inf')