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.
nos = int(input())
in_list = input().split()
start = int(in_list[0])
end = int(in_list[-1])
if start<end:
val = end
in_list.pop(-1)
else:
val = start
in_list.pop(0)
while len(in_list)>0:
start = int(in_list[0])
end = int(in_list[-1])
if val>=end and end>=start:
val = end
in_list.pop(-1)
elif val>=start and start>=end:
val = start
in_list.pop(0)
else:
print("No")
break
if len(in_list)==0:
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 →
N = int(input())
for _ in range(N):