Created
          December 19, 2016 05:16 
        
      - 
      
- 
        Save ttsugriy/712f7dfa90f1268299779bf02f9b8a12 to your computer and use it in GitHub Desktop. 
    Minimum moves to equal array.
  
        
  
    
      This file contains hidden or 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(const vector& nums) { | |
| int base = *min_element(nums.cbegin(), nums.cend()); | |
| return accumulate(nums.cbegin(), nums.cend(), 0) - base * nums.size(); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment