Array After Simultaneous Local-Extremum Updates. Each day, use the previous day's whole array to update every interior element simultaneously: increase it by1 if strictly smaller than both neighbors, decrease it by1 if strictly larger than both, and otherwise leave it.
### Problem
Each day, use the previous day's whole array to update every interior element simultaneously: increase it by 1 if strictly smaller than both neighbors, decrease it by 1 if strictly larger than both, and otherwise leave it. Endpoints never change. The source states the process eventually stops changing. Return that final array.
```cpp
class Solution {
public:
vector<int> transformArray(vector<int>& arr);
};
```
### Examples
**Example 1:**
```text
Input: arr = [1,4,1]
Output: [1,1,1]
Explanation: The center changes4->3->2->1 over three days, then is no longer a strict maximum.
```
**Example 2:**
```text
Input: arr = [3,1,2]
Output: [3,2,2]
Explanation: The center increases once, after which equality with its right neighbor prevents another update.
```
### Constraints
- The array contains 3 to 100 integers.
- Each original value is in `[1,100]`.
### Contract considerations
The return type is the original vector result; simultaneous daily evolution is part of the contract.
```hint Read the boundary condition
When an interior value equals either neighbor, do the strict-extremum rules require it to change?
```
### Boundary reminders
The return type is the original vector result; simultaneous daily evolution is part of the contract.
Overview: Array After Simultaneous Local-Extremum Updates. Each day, use the previous day's whole array to update every interior element simultaneously: increase it by1 if strictly smaller than both neighbors, decrease it by1 if strictly larger than both, and otherwise leave it.
Each day, use the previous day's whole array to update every interior element simultaneously: increase it by 1 if strictly smaller than both neighbors, decrease it by 1 if strictly larger than both, and otherwise leave it. Endpoints never change. The source states the process eventually stops changing. Return that final array.
class Solution {
public:
vector<int> transformArray(vector<int>& arr);
};
Examples
Example 1:
Input: arr = [1,4,1]
Output: [1,1,1]
Explanation: The center changes4->3->2->1 over three days, then is no longer a strict maximum.
Example 2:
Input: arr = [3,1,2]
Output: [3,2,2]
Explanation: The center increases once, after which equality with its right neighbor prevents another update.
Constraints
The array contains 3 to 100 integers.
Each original value is in
[1,100]
.
Contract considerations
The return type is the original vector result; simultaneous daily evolution is part of the contract.
Boundary reminders
The return type is the original vector result; simultaneous daily evolution is part of the contract.