✅Beats 93% | C++ | Python3
\n\n# Code\n\nC++ []\nclass Solution {\npublic:\n    int minMovesToSeat(vector<int>& seats, vector<int>& students) \n    {\n        sort(seats.begin(),seats.end
![Screenshot 2024-06-13 150928.png](https://assets.leetcode.com/users/images/26eff64b-7868-462d-8179-b42e02f8d38e_1718271689.2279572.png)\n\n# Code\n\n```C++ []\nclass Solution {\npublic:\n    int minMovesToSeat(vector<int>& seats, vector<int>& students) \n    {\n        sort(seats.begin(),seats.end());\n        sort(students.begin(),students.end());\n        int ans = 0;\n        for (int i=0;i<seats.size();i++)\n        {\n            ans += abs(seats[i]-students[i]);\n        }    \n        return ans;\n    }\n};\n```\n```python3 []\nclass Solution:\n    def minMovesToSeat(self, seats: List[int], students: List[int]) -> int:\n        seats.sort()\n        students.sort()\n        ans = 0\n        for i in range(len(seats)):\n            ans += abs(seats[i]-students[i])\n        return ans\n```\n\n\n\n\n
['C++']