# 941. Valid Mountain Array

[941. Valid Mountain Array](https://leetcode.com/problems/valid-mountain-array/)

```python
class Solution:
    def validMountainArray(self, arr: List[int]) -> bool:
        peak = 0
        n = len(arr)

        # Climb to the peak 
        for i in range(1, n):
            if arr[i] > arr[i - 1]:
                peak = i
            else:
                break

        # Climb to the peak 
        # - peak == 0: the starting point is the peak
        # - peak == n - 1: the ending point is the peak
        if peak == 0 or peak == n - 1:
            return False

        # Keep climbing to the end
        for i in range(peak, n - 1):
            # if next point is larger then current point, it goes up again. 
            if arr[i] <= arr[i + 1]:
                return False

        return True
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://garylai.gitbook.io/algorithm-and-data-structure/problems/array/valid-mountain-array.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
