by sorting | easiest approach
Intuition\n Describe your first thoughts on how to solve this problem. \nfirst sort both the arrays\nand we notice and the number of moves required will be Math
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nfirst sort both the arrays\nand we notice and the number of moves required will be Math.abs(seats[i]-students[i])\n\nso simply return it.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. sort the arrays and initialise total number of moves as 0.\n2. iterate over the seat array .\n3. compute the total number of moves.\n4. return the total number of moves\n\n# Complexity\n- Time complexity:O(n log n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g. $$O(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 move=0;\n        for(int i=0;i<seats.length;i++){\n            move=move+ Math.abs(seats[i]-students[i]);\n        }\n        return move;\n    }\n}\n```
['Java']