Created
October 23, 2021 16:16
-
-
Save Shivani13121007/e219efe0d9553accc1233181ea54f2ae to your computer and use it in GitHub Desktop.
Minimum Number of Moves to Seat Everyone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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