Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aea984e

Browse files
authoredMar 21, 2023
Update 1526-minimum-number-of-increments-on-subarrays-to-form-a-target-array.js
1 parent 093323a commit aea984e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
 

‎1526-minimum-number-of-increments-on-subarrays-to-form-a-target-array.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/**
2+
* @param {number[]} target
3+
* @return {number}
4+
*/
5+
const minNumberOperations = function(target) {
6+
let res = target[0]
7+
8+
for(let i = 1; i < target.length; i++) {
9+
res += Math.max(0, target[i] - target[i - 1])
10+
}
11+
12+
return res
13+
}
14+
15+
// another
16+
117
/**
218
* @param {number[]} target
319
* @return {number}

0 commit comments

Comments
 (0)
Please sign in to comment.