c++ solution


  • 0
    A

    class Solution {
    public:
    int minMoves(vector<int>& nums) {
    int sum = 0;
    sort(nums.begin(), nums.end());
    for(auto n = nums.begin(); n != nums.end(); n++){
    sum += *n;
    }
    int res = sum - nums[0] * nums.size();
    return res;
    }
    };


Log in to reply
 

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