Two C++ solutions
Solution 1 : Worked for all the test cases\n\nIdea:\nWe sort both arrays.\nThen, greedily, we loop through them and match each student with the closest seat.\n\
**Solution 1 : Worked for all the test cases**\n\n**Idea:**\nWe sort both arrays.\nThen, greedily, we loop through them and match each student with the closest seat.\n\n**Time Complexity: O(nlogn)**\n**Space Complexity: O(1)**\n```\nclass Solution {\npublic:\n    int minMovesToSeat(vector<int>& seats, vector<int>& students) {\n        sort(seats.begin(), seats.end());\n        sort(students.begin(), students.end());\n        int sum = 0;\n        for(int i = 0; i<seats.size(); i++)\n            sum += (abs(seats[i] - students[i]));\n        return sum;\n    }\n};\n```\n**Solution 2 : Worked for half of the test cases**\n\n**Idea:**\nWe just get the sum of the students and seats then return the difference\n\nTried for some brilliancy here but failed\uD83D\uDE05\uD83D\uDE05\n\n```\nclass Solution {\npublic:\n    int minMovesToSeat(vector<int>& seats, vector<int>& students) {\n         int se = accumulate(seats.begin(), seats.end(), 0);\n         int stu = accumulate(students.begin(), students.end(), 0);\n        \n         return abs(se - stu);\n\t}\n};\n```
['C', 'C++']