Skip to content

Commit 1960fc2

Browse files
Merge pull request #1 from Siddharth2812/Siddharth2812-patch-1
Create CheckForUnimodalArray.py
2 parents 3eb4e8e + 3a2d2ef commit 1960fc2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Python/CheckForUnimodalArray.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
n = int(input())
2+
l = list( map(int,input().split()))
3+
j = 0
4+
i = 0
5+
a = max(l)
6+
max_index = l.index(max(l))
7+
for i in range(0,n-1):
8+
if l[i] < l[i+1] :
9+
j = j+1
10+
else :
11+
break
12+
for i in range(i,n-1) :
13+
if l[i] == l[i+1] :
14+
j = j+1
15+
else :
16+
break
17+
for i in range(i,n-1) :
18+
if l[i] > l[i+1] :
19+
j = j+1
20+
else :
21+
break
22+
if j == n-1 :
23+
print("YES")
24+
else :
25+
print("NO")

0 commit comments

Comments
 (0)