Skip to content

Commit 28281f7

Browse files
authored
Create 1526-minimum-number-of-increments-on-subarrays-to-form-a-target-array.js
1 parent bc8c196 commit 28281f7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @param {number[]} target
3+
* @return {number}
4+
*/
5+
const minNumberOperations = function(target) {
6+
let totalOperations = target[0];
7+
for (let i = 1; i < target.length; ++i) {
8+
if (target[i] > target[i-1]) {
9+
totalOperations += target[i] - target[i-1];
10+
}
11+
}
12+
return totalOperations;
13+
};

0 commit comments

Comments
 (0)