Guest User

Untitled

a guest
Jan 16th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. class Solution {
  2. public:
  3. int minMoves2(vector<int>& nums) {
  4. sort(nums.begin(), nums.end());
  5. int ans = 0;
  6. int start = 0, end = nums.size()-1;
  7.  
  8. while(start < end) {
  9. ans += nums[end--] - nums[start++];
  10. }
  11.  
  12. return ans;
  13. }
  14. };
Add Comment
Please, Sign In to add comment