Description
Solutions
Focus on Efficiency (2024 NG)
π₯ FULLTIMEπRELATED PROBLEMS
Given an array of integers A
, with each move you can select an arbitrary range and increment all the numbers in that range by 1. Return the number of moves needed to transform an array starting with all zeros into A
.
Example 1:
Input: A = [2, 1, 3]
Output: 4
Explanation:To transform
[0, 0, 0]
into[2, 1, 3]
requires 4 moves, as follows:
[0, 0, 0]
->[1, 1, 1]
->[2, 1, 1]
->[2, 1, 2]
->[2, 1, 3]
Constraints:
π
π

Related Problems
Testcase
Result
Case 1
input:
output: