explanation of question with code
The question demands for minimun postition to place n students in n seats after moving them from their current position to the closest seat present from their p
The question demands for minimun postition to place n students in n seats after moving them from their current position to the closest seat present from their position \n\nso ,the algorithm goes like this:\n* firstly sort both the arrays \n* this will match the minimum position student with the closest seat present from them \n* start a loop traversing the student array and find the difference of position from his seat to the minimum seat availabe \n* add all the differences in a variable and return the end result\n\n\n\t\tint minMovesToSeat(vector<int>& seats, vector<int>& students) {\n        sort(seats.begin(),seats.end());\n        sort(students.begin(),students.end());\n        int res=0;\n        for(int i=0;i<students.size();i++)\n        {\n            res=res+(abs(students[i]-seats[i]));\n        }\n        return res;\n    }
['C', 'Sorting']