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 STDOUTn=int(input())defisVertical(blocks):stk=[float('inf')]whilelen(blocks):ifblocks[0]>=blocks[-1]:ifstk[-1]>=blocks[0]:stk.append(blocks.pop(0))else:return'No'else:ifstk[-1]>=blocks[-1]:stk.append(blocks.pop(-1))else:return'No'return'Yes'foriinrange(n):size=int(input())blocks=list(map(int,input().split()))print(isVertical(blocks))
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 →