Task Asssignment Time : O(nlogn) Space : O(n) 12345678910111213vector<vector<int>> taskAssignment(int k, vector<int> tasks) { vector<pair<int,int>> vpi; for(int i = 0; i < 2*k; i++) { vpi.push_back({tasks[i],i}); } sort(begin(vpi),end(vpi)); vector<vector<int>> res; for(int i = 0, j = 2*k-1; i < k; i++,j--) { res.push_back({vpi[i].second, vpi[j].second}); } return res;}