Simple Sorting Method [C++]
Sort both arrays as this way the difference between student & seat at ith position will be minimum.\n\n\nclass Solution {\npublic:\n    int minMovesToSeat(vecto
Sort both arrays as this way the difference between student & seat at ```i```th position will be minimum.\n\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 cnt=0,diff;\n        for(int i=0;i<seats.size();i++){\n            diff = max(seats[i],students[i]) - min(seats[i],students[i]);\n            cnt+=diff;\n        }\n        return cnt;\n    }\n};\n```
[]