C++ Sorting
See my latest update in repo LeetCode\n## Solution 1. Sorting\n\nSort both arrays. Match each seat to the corresponding student with the same index with abs(sea
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n## Solution 1. Sorting\n\nSort both arrays. Match each seat to the corresponding student with the same index with `abs(seats[i] - students[i])` moves.\n\n```cpp\n// OJ: https://leetcode.com/problems/minimum-number-of-moves-to-seat-everyone/\n// Author: github.com/lzl124631x\n// Time: O(NlogN)\n// Space: O(1)\nclass Solution {\npublic:\n    int minMovesToSeat(vector<int>& A, vector<int>& B) {\n        sort(begin(A), end(A));\n        sort(begin(B), end(B));\n        int ans = 0;\n        for (int i = 0; i < A.size(); ++i) {\n            ans += abs(A[i] - B[i]);\n        }\n        return ans;\n    }\n};\n```
[]