← 返回 amazon 的题目列表Transform Array to Uniform Value
类型:online_judge
Given an integer array, your goal is to transform every element into k by performing a series of operations. Each operation allows you to pick a segment ending at the last element and either increase or decrease every number in that segment by 1. Your task is to determine the smallest number of operations needed to reduce all numbers in the array to k.
Example
Input
3
1 5 7
4