You are viewing a single comment's thread. Return to all comments →
T = int(input()) blocks = [] for i in range(T): n = int(input()) block = list(map(int,input().split())) start = 0 end = n-1 stack = [] for i in range(n): left = block[start] right = block[end] if i == 0: if left >= right: stack.append(left) start +=1 else: stack.append(right) end -=1 else: if left <= stack[-1] and left >= right: stack.append(left) start +=1 elif right <= stack[-1] and right > left: stack.append(right) end -=1 else: print('No') break if (len(stack) == n): print('Yes')
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 →