Created
December 19, 2016 06:44
-
-
Save ttsugriy/c23e83ccd7589a2120c150d5e43983e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int minMoves(vector<int>& nums) { | |
int base = numeric_limits<int>::max(); | |
int sum = 0; | |
for (int i = 0; i < nums.size(); ++i) { | |
sum += nums[i]; | |
base = min(base, nums[i]); | |
} | |
return sum - base * nums.size(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment