Pure math problem


  • 0
    F

    Re: It is a math question
    Just solve a equation.

    class Solution {
        public int minMoves(int[] nums) {
            int min = Integer.MAX_VALUE;
            int sum = 0;
            for (int num : nums) {
                sum += num;
                min = Math.min(min, num);
            }
            int a = sum - (nums.length - 1) * min;
            return a - min;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.