Minimum Number of Increments on Subarrays to Form a Target Array LeetCode solution in Rust

1
impl Solution {
2
pub fn min_number_operations(target: Vec<i32>) -> i32 {
3
let mut ans = 0;
4
let mut prev = 0;
5
for &x in target.iter() {
6
if x > prev {
7
ans += x - prev;
8
}
9
prev = x;
10
}
11
ans
12
}
13
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0