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.
I am not sure when did things turned into the wrong but i got all of my test case right except for the first two one's
possible = True
for _ in range(int(input())):
block = int(input())
block_dict = list(int(i) for i in list(input().split()))
answers = [block_dict[0] if block_dict[0] > block_dict[-1] else block_dict[0] if len(block_dict) == 1 else block_dict[-1]]
block_dict.remove(answers[0])
for i in range(len(block_dict)):
x = max(block_dict[0], block_dict[-1]) if len(block_dict) > 1 else block_dict[0]
if x <= answers[i]:
answers.append(x)
else:
possible = False
break
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 →
I am not sure when did things turned into the wrong but i got all of my test case right except for the first two one's possible = True for _ in range(int(input())): block = int(input()) block_dict = list(int(i) for i in list(input().split())) answers = [block_dict[0] if block_dict[0] > block_dict[-1] else block_dict[0] if len(block_dict) == 1 else block_dict[-1]] block_dict.remove(answers[0]) for i in range(len(block_dict)): x = max(block_dict[0], block_dict[-1]) if len(block_dict) > 1 else block_dict[0] if x <= answers[i]: answers.append(x) else: possible = False break print("Yes" if possible else "No")