3736. Minimum Moves to Equal Array Elements III Easy

@problem@discussion
#Array#Math



1/**
2 * [3736] Minimum Moves to Equal Array Elements III
3 *
4 * You are given an integer array nums.
5 * In one move, you may increase the value of any single element nums[i] by 1.
6 * Return the minimum total number of moves required so that all elements in nums become equal.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">nums = [2,1,3]</span>
11 * Output: <span class="example-io">3</span>
12 * Explanation:
13 * To make all elements equal:
14 * 
15 * 	Increase nums[0] = 2 by 1 to make it 3.
16 * 	Increase nums[1] = 1 by 1 to make it 2.
17 * 	Increase nums[1] = 2 by 1 to make it 3.
18 * 
19 * Now, all elements of nums are equal to 3. The minimum total moves is 3.
20 * </div>
21 * <strong class="example">Example 2:
22 * <div class="example-block">
23 * Input: <span class="example-io">nums = [4,4,5]</span>
24 * Output: <span class="example-io">2</span>
25 * Explanation:
26 * To make all elements equal:
27 * 
28 * 	Increase nums[0] = 4 by 1 to make it 5.
29 * 	Increase nums[1] = 4 by 1 to make it 5.
30 * 
31 * Now, all elements of nums are equal to 5. The minimum total moves is 2.
32 * </div>
33 *  
34 * Constraints:
35 * 
36 * 	1 <= nums.length <= 100
37 * 	1 <= nums[i] <= 100
38 * 
39 */
40pub struct Solution {}
41
42// problem: https://leetcode.com/problems/minimum-moves-to-equal-array-elements-iii/
43// discuss: https://leetcode.com/problems/minimum-moves-to-equal-array-elements-iii/discuss/?currentPage=1&orderBy=most_votes&query=
44
45// submission codes start here
46
47impl Solution {
48    pub fn min_moves(nums: Vec<i32>) -> i32 {
49        0
50    }
51}
52
53// submission codes end
54
55#[cfg(test)]
56mod tests {
57    use super::*;
58
59    #[test]
60    fn test_3736() {
61    }
62}
63

Back
© 2026 bowen.ge All Rights Reserved.