Tap here to switch tabs
Problem
Submissions

Problem: Array Transformation

med
30 min
Try to solve the Array Transformation problem.

Statement

Given an initial integer array arr, repeatedly modify the elements simultaneously based on the following rules:

  • An element is incremented by 11 if it is strictly smaller than both its left neighbor and its right neighbor.

  • An element is decremented by 11 if it is strictly greater than both its left neighbor and its right neighbor.

  • The first and last elements of the array never change.

This modification process is applied repeatedly until the array stops changing. Return the final modified array.

Constraints:

  • 3≤3 \leq arr.length ≤100\leq 100

  • 1≤1 \leq arr[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Array Transformation

med
30 min
Try to solve the Array Transformation problem.

Statement

Given an initial integer array arr, repeatedly modify the elements simultaneously based on the following rules:

  • An element is incremented by 11 if it is strictly smaller than both its left neighbor and its right neighbor.

  • An element is decremented by 11 if it is strictly greater than both its left neighbor and its right neighbor.

  • The first and last elements of the array never change.

This modification process is applied repeatedly until the array stops changing. Return the final modified array.

Constraints:

  • 3≤3 \leq arr.length ≤100\leq 100

  • 1≤1 \leq arr[i] ≤100\leq 100