[Java] Sort and find difference
This solution has O(n log n) time complexity.\n\nBy sorting both input arrays, you ensure that the number of moves is the lowest because the student with the lo
This solution has O(n log n) time complexity.\n\nBy sorting both input arrays, you ensure that the number of moves is the lowest because the student with the lowest position moves to the lowest seat, and the student with the highest position moves to the highest seat.\n\n```\npublic int minMovesToSeat(int[] seats, int[] students) {\n        Arrays.sort(seats);\n        Arrays.sort(students);\n        int count = 0;\n        for (int i=0; i<seats.length; i++) {\n            count += Math.abs(seats[i] - students[i]);\n        }\n        return count;\n    }\n```
[]