easy & understanding Java solution
Intuition\nTo solve the problem of finding the minimum moves to seat students, my initial thoughts would be to consider the distance between each student and th
# Intuition\nTo solve the problem of finding the minimum moves to seat students, my initial thoughts would be to consider the distance between each student and their corresponding seat.\n\nSort the arrays: The first step would be to sort both the seats and students arrays. Sorting allows us to match students with seats more efficiently.\n\n Calculate the sum of absolute differences: Iterate over both arrays simultaneously, calculating the absolute difference between each student\'s position and their corresponding seat\'s position. Sum up these absolute differences.\n\n Return the sum: Once we have the sum of absolute differences, return it as the minimum moves required to seat the students optimally.\n\nThis approach ensures that we minimize the total distance traveled by students to their respective seats.\n\n\n# Complexity\n- Time complexity: O(n log n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n\n# Code\n```\nclass Solution {\n    public int minMovesToSeat(int[] seats, int[] students) {\n        Arrays.sort(seats);\n        Arrays.sort(students);\n        int n=seats.length;\n        int sum=0;\n        for(int i=0;i<n;i++){\n            sum += Math.abs(seats[i]-students[i]);\n        }\n        return sum;\n    }\n}\n```
['Java']