forked from oktavandi/Hacktober2020
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMountainArray.py
More file actions
28 lines (28 loc) · 851 Bytes
/
Copy pathMountainArray.py
File metadata and controls
28 lines (28 loc) · 851 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
def validMountainArray(self, A: List[int]) -> bool:
if len(A)<3:
return False
else:
t,t2=A[0],A[len(A)-1]
for i in range (len(A)-1):
if A[i]==A[i+1]:
return False
elif A[i]<A[i+1]:
continue
else:
t,j=A[i],i
print(t,j)
break
for i in range(len(A)-2,-1,-1):
if A[i]==A[i+1]:
return False
elif A[i]>A[i+1]:
continue
else:
t2,j2=A[i+1],i+1
print(t2,j2)
break
if t==t2 and j==j2:
#print(t,t2)
return True
else:
return False