# 852.Peak Index in A Mountain Array

**852.Peak Index in a Mountain Array**

> 我们把符合下列属性的数组 A 称作山脉： A.length >= 3 存在 0 < i < A.length - 1 使得A\[0] < A\[1] < ... A\[i-1] < A\[i] > A\[i+1] > ... > A\[A.length - 1] 给定一个确定为山脉的数组，返回任何满足 A\[0] < A\[1] < ... A\[i-1] < A\[i] > A\[i+1] > ... > A\[A.length - 1] 的 i 的值。

示例 1：

```
输入：[0,1,0]
输出：1
```

示例 2：

```
输入：[0,2,1,0]
输出：1
```

提示：

```
3 <= A.length <= 10000
0 <= A[i] <= 10^6
A 是如上定义的山脉
```

方法：这题太简单，找出最大值索引即可。

```
class Solution {
public:
    int peakIndexInMountainArray(vector<int>& A) {
        int n=A.size();
        int k=0;
        for (int i=0;i<n;i++)
            k=  (A[i] > A[k]) ?i : k;
        return k;
    }
};
```


---

# 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://dfine.gitbook.io/leetcode/852.peak_index_in_a_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.
