# Find All Strict Interior Peak Indices
You are given a 0-indexed integer array `mountain`. An interior index `i` is a peak when its value is strictly greater than both neighboring values: `mountain[i] > mountain[i - 1]` and `mountain[i] > mountain[i + 1]`.
The first and last indices are never peaks. Return the indices of all peaks in any order.
### Examples
**Example 1**
```text
Input: mountain = [5,9,2,6,1,7]
Output: [1,3]
```
Value `9` at index `1` is greater than `5` and `2`; value `6` at index `3` is greater than `2` and `1`. The final value `7` is not eligible because it is an endpoint. Returning `[3,1]` would also be valid.
**Example 2**
```text
Input: mountain = [7,4,4,2]
Output: []
```
The interior values at indices `1` and `2` each equal a neighbor, so neither is strictly greater than both neighbors. Endpoints are excluded.
### Constraints
- `3 <= mountain.length <= 100`.
- `1 <= mountain[i] <= 100`.
### Clarifying Questions
- Do equal neighboring values form a peak? No; both comparisons must be strict.
- Can the first or last position qualify? No, regardless of its value.
- Does the name `mountain` guarantee a single peak or a rise followed by a fall? No such shape promise is given; find every index satisfying the local definition.
- Must peak indices be sorted? No; any order is permitted.
- What should be returned when no peak exists? An empty array.
### C++ Interface
```cpp
class Solution {
public:
vector<int> findPeaks(vector<int>& mountain) {
}
};
```
### Reasoning Checkpoints
- Apply the strict two-neighbor definition without assuming a global array shape.
- Exclude endpoints and include every qualifying interior index exactly once.
- Preserve the any-order result contract and distinguish output storage from working space.
```hint Check each eligible position
Inspect only indices with both a left and a right neighbor. What two comparisons exactly match the peak definition?
```
Overview: Return all interior indices whose array values strictly exceed both neighbors, excluding endpoints and allowing any order of peak indices.
You are given a 0-indexed integer array mountain. An interior index i is a peak when its value is strictly greater than both neighboring values: mountain[i] > mountain[i - 1] and mountain[i] > mountain[i + 1].
The first and last indices are never peaks. Return the indices of all peaks in any order.
Examples
Example 1
Input: mountain = [5,9,2,6,1,7]
Output: [1,3]
Value 9 at index 1 is greater than 5 and 2; value 6 at index 3 is greater than 2 and 1. The final value 7 is not eligible because it is an endpoint. Returning [3,1] would also be valid.
Example 2
Input: mountain = [7,4,4,2]
Output: []
The interior values at indices 1 and 2 each equal a neighbor, so neither is strictly greater than both neighbors. Endpoints are excluded.
Constraints
3 <= mountain.length <= 100
.
1 <= mountain[i] <= 100
.
Clarifying Questions Guidance
Do equal neighboring values form a peak? No; both comparisons must be strict.
Can the first or last position qualify? No, regardless of its value.
Does the name
mountain
guarantee a single peak or a rise followed by a fall? No such shape promise is given; find every index satisfying the local definition.
Must peak indices be sorted? No; any order is permitted.
What should be returned when no peak exists? An empty array.
C++ Interface
class Solution {
public:
vector<int> findPeaks(vector<int>& mountain) {
}
};
Reasoning Checkpoints
Apply the strict two-neighbor definition without assuming a global array shape.
Exclude endpoints and include every qualifying interior index exactly once.
Preserve the any-order result contract and distinguish output storage from working space.