1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
fn main() { println!("Hello, world!"); } struct Solution {} impl Solution { pub fn candy(ratings: Vec<i32>) -> i32 { let result = Vec::with_capacity(ratings.len()); let mut candy = 1; while let Some(s)= ratings.iter().enumerate() .fold(i32::MAX, |acc, (i,v)| if v < acc && {v}) result.iter().sum::<i32>() } }