|
4 | 4 | import java.util.List;
|
5 | 5 | import java.util.stream.Collectors;
|
6 | 6 |
|
7 |
| -/** |
8 |
| - * 1243. Array Transformation |
9 |
| - * |
10 |
| - * Given an initial array arr, every day you produce a new array using the array of the previous day. |
11 |
| - * |
12 |
| - * On the i-th day, you do the following operations on the array of day i-1 to produce the array of day i: |
13 |
| - * |
14 |
| - * If an element is smaller than both its left neighbor and its right neighbor, then this element is incremented. |
15 |
| - * If an element is bigger than both its left neighbor and its right neighbor, then this element is decremented. |
16 |
| - * The first and last elements never change. |
17 |
| - * After some days, the array does not change. Return that final array. |
18 |
| - * |
19 |
| - * Example 1: |
20 |
| - * Input: arr = [6,2,3,4] |
21 |
| - * Output: [6,3,3,4] |
22 |
| - * Explanation: |
23 |
| - * On the first day, the array is changed from [6,2,3,4] to [6,3,3,4]. |
24 |
| - * No more operations can be done to this array. |
25 |
| - * |
26 |
| - * Example 2: |
27 |
| - * Input: arr = [1,6,3,4,3,5] |
28 |
| - * Output: [1,4,4,4,4,5] |
29 |
| - * Explanation: |
30 |
| - * On the first day, the array is changed from [1,6,3,4,3,5] to [1,5,4,3,4,5]. |
31 |
| - * On the second day, the array is changed from [1,5,4,3,4,5] to [1,4,4,4,4,5]. |
32 |
| - * No more operations can be done to this array. |
33 |
| - * |
34 |
| - * Constraints: |
35 |
| - * 1 <= arr.length <= 100 |
36 |
| - * 1 <= arr[i] <= 100 |
37 |
| - * */ |
38 | 7 | public class _1243 {
|
39 | 8 | public static class Solution1 {
|
40 | 9 | public List<Integer> transformArray(int[] arr) {
|
|
0 commit comments