# iven an array A of integers, return true if and only if it is a valid mountain array.

# Recall that A is a mountain array if and only if:

# A.length >= 3
# There exists some i with 0 < i < A.length - 1 such that:
# A[0] < A[1] < ... A[i-1] < A[i]
# A[i] > A[i+1] > ... > A[B.length - 1]


# Example 1:

# Input: [2,1]
# Output: false
# Example 2:

# Input: [3,5,5]
# Output: false
# Example 3:

# Input: [0,3,2,1]
# Output: true


class Solution:
    def validMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: bool
        """
        if len(A) < 3:
            return false
        max_num = max(A)
        index = A.index(max_num)
        if index < len(A) - 1:
            return self.isIncrease(A[:index]) and self.isDecrease(A[index:])
        else:
            return False

    def isIncrease(self, A):
        return all(A[i] - A[i + 1] < 0 for i in range(len(A) - 1))

    def isDecrease(self, A):
        return all(A[i] - A[i + 1] > 0 for i in range(len(A) - 1))


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

0d5ebaa96f826fd34b89f35c3d8a6ff6fec20268
class Solution:

    def validMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: bool
        """
        if len(A) < 3:
            return false
        max_num = max(A)
        index = A.index(max_num)
        if index < len(A) - 1:
            return self.isIncrease(A[:index]) and self.isDecrease(A[index:])
        else:
            return False
    <mask token>
    <mask token>


<mask token>

class Solution:

    def validMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: bool
        """
        if len(A) < 3:
            return false
        max_num = max(A)
        index = A.index(max_num)
        if index < len(A) - 1:
            return self.isIncrease(A[:index]) and self.isDecrease(A[index:])
        else:
            return False

    def isIncrease(self, A):
        return all(A[i] - A[i + 1] < 0 for i in range(len(A) - 1))
    <mask token>


<mask token>

class Solution:

    def validMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: bool
        """
        if len(A) < 3:
            return false
        max_num = max(A)
        index = A.index(max_num)
        if index < len(A) - 1:
            return self.isIncrease(A[:index]) and self.isDecrease(A[index:])
        else:
            return False

    def isIncrease(self, A):
        return all(A[i] - A[i + 1] < 0 for i in range(len(A) - 1))

    def isDecrease(self, A):
        return all(A[i] - A[i + 1] > 0 for i in range(len(A) - 1))


<mask token>

class Solution:

    def validMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: bool
        """
        if len(A) < 3:
            return false
        max_num = max(A)
        index = A.index(max_num)
        if index < len(A) - 1:
            return self.isIncrease(A[:index]) and self.isDecrease(A[index:])
        else:
            return False

    def isIncrease(self, A):
        return all(A[i] - A[i + 1] < 0 for i in range(len(A) - 1))

    def isDecrease(self, A):
        return all(A[i] - A[i + 1] > 0 for i in range(len(A) - 1))


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

# iven an array A of integers, return true if and only if it is a valid mountain array.

# Recall that A is a mountain array if and only if:

# A.length >= 3
# There exists some i with 0 < i < A.length - 1 such that:
# A[0] < A[1] < ... A[i-1] < A[i]
# A[i] > A[i+1] > ... > A[B.length - 1]


# Example 1:

# Input: [2,1]
# Output: false
# Example 2:

# Input: [3,5,5]
# Output: false
# Example 3:

# Input: [0,3,2,1]
# Output: true


class Solution:
    def validMountainArray(self, A):
        """
        :type A: List[int]
        :rtype: bool
        """
        if len(A) < 3:
            return false
        max_num = max(A)
        index = A.index(max_num)
        if index < len(A) - 1:
            return self.isIncrease(A[:index]) and self.isDecrease(A[index:])
        else:
            return False

    def isIncrease(self, A):
        return all(A[i] - A[i + 1] < 0 for i in range(len(A) - 1))

    def isDecrease(self, A):
        return all(A[i] - A[i + 1] > 0 for i in range(len(A) - 1))


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