LeetCode Entry

3736. Minimum Moves to Equal Array Elements III

03.11.2026 easy 2026 kotlin rust

Min +1 moves to make all equal

3736. Minimum Moves to Equal Array Elements III easy substack youtube

https://dmitrysamoylenko.com/leetcode/

03.11.2026.webp

Join me on Telegram

https://t.me/leetcode_daily_unstoppable/1531

Problem TLDR

Min +1 moves to make all equal

Intuition

Up each to the maximum

Approach

  • or look at geometry area of maximum * length - sum()

Complexity

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

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

Code

    fun minMoves(n: IntArray) =
        n.sumOf{n.max()-it}
    pub fn min_moves(n: Vec<i32>) -> i32 {
        fold(&n,0,|a,x|a+max(&n).unwrap()-x)
    }

Comments