Easy C++ Solution with Video Explanation
Video Explanation\nhttps://youtu.be/GprqsrxsccE?si=8M7XqaeBAcPteOhp\n# Complexity\n- Time complexity:O(n log n)\n Add your time complexity here, e.g. O(n) \n\n-
# Video Explanation\nhttps://youtu.be/GprqsrxsccE?si=8M7XqaeBAcPteOhp\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 {\npublic:\n    int minMovesToSeat(vector<int>& seats, vector<int>& students) {\n        \n        int n = seats.size();\n\n        sort(seats.begin(),seats.end());\n        sort(students.begin(),students.end());\n\n        int result = 0;\n\n        for(int i=0;i<n;i++){\n\n            result += abs(seats[i]-students[i]);\n            \n        }\n\n        return result;\n    }\n};\n```
['C++']