Skip to content

Commit

Permalink
Time: 2 ms (97.35%), Space: 44.6 MB (9.02%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
kjy0349 committed Jun 13, 2024
1 parent fde1710 commit cac5aac
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import java.util.*;
class Solution {
public int minMovesToSeat(int[] seats, int[] students) {
Arrays.sort(seats);
Arrays.sort(students);
int answer = 0;
for (int i = 0; i < seats.length; i++) {
answer += Math.abs(seats[i] - students[i]);
}
return answer;
}
}

0 comments on commit cac5aac

Please sign in to comment.