public class Solution {
    public int MinMoves(int[] nums) {
        var list = nums.OrderBy(x => x).ToList();

            var sum = 0;

            for (int i = 1; i < list.Count; i++)
            {
                sum += list[i] - list[0];
            }
            Console.WriteLine(sum);
            return sum;
    }
}

https://leetcode.com/problems/minimum-moves-to-equal-array-elements/#/description

posted on 2017-04-19 11:10  Sempron2800+  阅读(119)  评论(0编辑  收藏  举报