2019-11-10 LeetCode in Rust LeetCode 1144. Decrease Elements To Make Array Zigzag Problem Statement impl Solution { pub fn moves_to_make_zigzag(nums: Vec<i32>) -> i32 { use std::cmp; let mut moves = vec![0, 0]; let (mut l, mut r) = (0, 0); for i in 0..nums.len() { if i == 0 { l = std::i32::MAX; } else { l = nums[i - 1]; } if i == nums.len() - 1 { r = std::i32::MAX; } else { r = nums[i + 1]; } moves[i % 2] += cmp::max(0, nums[i] - cmp::min(l, r) + 1); } return std::cmp::min(moves[0], moves[1]); }} Newer LeetCode 1143. Longest Common Subsequence Older LeetCode 1161. Maximum Level Sum of a Binary Tree