Simple C++ 5 lines solution


  • 0
     int minMoves(vector<int>& nums) {
            int min=nums[0];
            int moves=0;
            for(int i:nums) if(i<min) min=i;
            for(int i:nums) moves+=i-min;
            return moves;
        }
    

Log in to reply
 

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