class Solution(object):
    def validMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: bool
        """
        if len(A) < 3:
            return False
        m, idx = max(A), 0,
        if A[0] == m or A[-1] == m:
            return False

        for i in xrange(len(A)):
            if i and A[i] < A[i - 1]:
                idx = i - 1
                if A[i - 1] != m:
                    return False
                break

        for i in xrange(idx + 1):
            if i and A[i] <= A[i - 1]:
                return False

        for i in xrange(idx + 1, len(A)):
            if A[i] >= A[i - 1]:
                return False

        return True


if __name__ == '__main__':
    print Solution().validMountainArray([2, 1])
    print Solution().validMountainArray([3, 5, 5])
    print Solution().validMountainArray([0, 3, 2, 1])
