Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Min Moves
public class Solution {
public int minMoves2(int[] nums) {
int sum = 0;
for (int num : nums) {
sum += Math.abs(nums[nums.length / 2] - num);
return sum;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment