public class Solution {
public int minMoves2(int[] nums) {
Arrays.sort(nums);
int n = nums.length;
int pivot = nums[n / 2];
int count = 0;
for (int num : nums) count += Math.abs(num  pivot);
return count;
}
}
Share my Java concise solution

@rmn Hi rmn, I think this problem is just a 1D version of Best Meeting Point. Imagine if we have two persons on a straight line, then any point in between is the best meet point(including these two points). If we have three people on a straight line, the we should meet at the middle point. You can try if there are many persons on a line.