Trains the technique from
LeetCode 1243Array TransformationThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A row of gauges reads arr. Every round, all the gauges are updated at once from the readings the row held at the start of that round:
Rounds continue until a round changes nothing. Return the row as it then stands.
Example 1
In the first round the gauge reading 3 at position 1 has 1 and 2 either side, both lower, so it falls to 2, while the gauge reading 2 has 3 and 3 either side, both higher, so it rises to 3. The next round changes nothing.
Example 2
The middle gauge rises by one each round while both neighbours stay higher, and it stops once it reaches them.
Example 3
The middle gauge has one neighbour above and one below, so it never moves, and the two ends never move either.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def settle_gauges(arr: list[int]) -> list[int]:public List<Integer> settleGauges(int[] arr)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.