Given a non-empty integer array of size n, find the minimum number of moves required to make all array elements equal, where a move is incrementing n - 1 elements by 1.

Example:

Input:
[1,2,3] Output:
3 Explanation:
Only three moves are needed (remember each move increments two elements): [1,2,3] => [2,3,3] => [3,4,3] => [4,4,4]
class Solution(object):
def minMoves(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
total=0
m=min(nums)
for i in nums:
total+=i-m
return total

  

最新文章

  1. 对于前端JS、Html、CSS的大小、位置是否影响网站的相应时间
  2. 第二章 Mybatis代码生成工具
  3. ubuntu硬盘安装卡在探测文件系统
  4. linux的vim按了ctrl+s之后假死的解决办法
  5. 通过CreateOleObject控制IE
  6. lua学习笔记1
  7. JS Dom节点操作demo!
  8. Docker 部署DropWizard
  9. linux的8小时差问题解决
  10. Python--day10(函数(使用、分类、返回值))
  11. Python Mongodb接口
  12. Python自学:第二章 Python之禅
  13. java多线程系列6 synchronized 加强版 ReentrantLock
  14. 编程实现类似Linux下cp功能
  15. 【数据库】left join(左关联)、right join(右关联)、inner join(自关联)的区别
  16. [vue]webpack中使用组件
  17. Leetcode122-Best Time to Buy and Sell Stock II-Easy
  18. MySQL(2)数据库 表的查询操作
  19. 002_更新Nginx证书
  20. git之移除.idea

热门文章

  1. id: cannot find name for user ID xxx处理办法
  2. Python isspace() 方法检测字符串是否只由空格组成。
  3. Win10系列:UWP界面布局进阶2
  4. 用linq和datatable巧妙应用于微软报表rdlc
  5. 求1+2+……+n的和
  6. UVa Live 3635 - Pie 贪心,较小的可能不用 难度: 2
  7. macOS Sierra 如何打开任何来源
  8. spin lock自旋锁 双链表操作(多线程安全)(Ring0)
  9. 无法获取 vmci 驱动程序版本: 句柄无效
  10. C++四种类型之间的转换