MY SOLUTION


  • 1
    F
    public class Solution {
        public int minMoves(int[] nums) {
            int min = Integer.MAX_VALUE;
            int total = 0;
    
            for (int n : nums) {
                if ( n < min) min = n;
            }
    
            for (int n : nums) {
                total += n - min;
            }
    
            return total;
        }
    }

Log in to reply
 

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