forked from nathan-abela/HackerRank-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08 - Piling Up!.py
More file actions
38 lines (30 loc) · 792 Bytes
/
08 - Piling Up!.py
File metadata and controls
38 lines (30 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/piling-up/problem
# Difficulty: Medium
# Max Score: 50
# Language: Python
# ========================
# Solution
# ========================
ANS = []
T = int(input())
for _ in range(T):
n = int(input())
sl = list(map(int, input().split()))
for _ in range(n-1):
if sl[0] >= sl[len(sl)-1]:
a = sl[0]
sl.pop(0)
elif sl[0] < sl[len(sl)-1]:
a = sl[len(sl)-1]
sl.pop(len(sl)-1)
else:
pass
if len(sl) == 1:
ANS.append("Yes")
if((sl[0] > a) or (sl[len(sl)-1] > a)):
ANS.append("No")
break
print("\n".join(ANS))