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 STDOUTfromcollectionsimportdequefor_inrange(int(input())):n=int(input())blocks=deque(map(int,input().split()))top_cube=0whileblocks:left_most=blocks[0]right_most=blocks[-1]left_greater=left_most>right_mostnext_cube=left_mostifleft_greaterelseright_mostifnottop_cubeornext_cube<=top_cube:top_cube=blocks.popleft()ifleft_greaterelseblocks.pop()else:top_cube=0breakprint("Yes"iftop_cubeelse"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 →