Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shivani13121007/e219efe0d9553accc1233181ea54f2ae to your computer and use it in GitHub Desktop.
Save Shivani13121007/e219efe0d9553accc1233181ea54f2ae to your computer and use it in GitHub Desktop.
Minimum Number of Moves to Seat Everyone
class Solution {
public int minMovesToSeat(int[] seats, int[] students) {
Arrays.sort(seats);
Arrays.sort(students);
int ans = 0;
for(int i=0;i<seats.length;i++)
{
ans+= Math.abs(seats[i] - students[i]);
}
return ans;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment