Final Prices With a Special Discount in a Shop LeetCode solution in Rust

1
impl Solution {
2
pub fn final_prices(prices: Vec<i32>) -> Vec<i32> {
3
let mut res = Vec::with_capacity(prices.len());
4
'main: for (i, &ai) in prices.iter().enumerate() {
5
for &aj in prices.iter().skip(i + 1) {
6
if aj <= ai {
7
res.push(ai - aj);
8
continue 'main;
9
}
10
}
11
res.push(ai);
12
}
13
res
14
}
15
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0