| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/tehsints/LeetCode-Solutions/master/Python/valid-mountain-array.py | [Back] [Original] |
# Time: O(n)
# Space: O(1)
class Solution(object):
def validMountainArray(self, A):
"""
:type A: List[int]
:rtype: bool
"""
i = 0
while i+1 < len(A) and A[i] < A[i+1]:
i += 1
j = len(A)-1
while j-1 >= 0 and A[j-1] > A[j]:
j -= 1
return 0 < i == j < len(A)-1
| Web Proxy Viewer | New URL | Original Page |