LeetCode Entry

453. Minimum Moves to Equal Array Elements

01.11.2026 medium 2026 kotlin rust

Min increments of all except one to make equal

453. Minimum Moves to Equal Array Elements medium substack youtube

https://dmitrysamoylenko.com/leetcode/

01.11.2026.webp

Join me on Telegram

https://t.me/leetcode_daily_unstoppable/1529

Problem TLDR

Min increments of all except one to make equal

Intuition

Each number got incremented by it’s difference with min.

Approach

  • we can sort and simulate or just find the min

Complexity

  • Time complexity: \(O(n)\)

  • Space complexity: \(O(1)\)

Code

    fun minMoves(n: IntArray) =
        n.sum()-n.size*n.min()
    pub fn min_moves(mut n: Vec<i32>) -> i32 {
        n.sort();n.iter().map(|x|x-n[0]).sum()
    }

Comments