Get the Fewest Moves (~Operations~)~
Similar to LC 2772
You are given an integer list named data. The objective is to adjust all elements in this list so that each becomes zero. You can carry out the following move any number of times:
Your task is to figure out the fewest moves required to turn all the elements into zero.
A prefix is a contiguous group of items that includes the first element in the cart. for example [1], [1,2], [1,2,3] are prefixes of [1,2,3,4,5].
The function you implement should print a single number — the minimum number of steps needed.
A prefix segment refers to a continuous collection of elements starting from the first item in the sequence. For instance, [1], [1, 2], [1, 2, 3], and so on are valid prefixes of the sequence [1, 2, 3, 4, 5].
It is assured that turning all values in the list to zero is always achievable.
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
1 ≤ n ≤ 10^5-10^9 ≤ data[i] ≤ 10^9