题目:
代码(首刷看解析 2024年2月15日):
class Solution {
static bool cmp(const vector<int>& A, const vector<int>& B) {if(A[0] == B[0]) return A[1] < B[1];return A[0] > B[0];
}
public:vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {sort(people.begin(), people.end(), cmp);list<vector<int>> que;for (int i = 0; i < people.size(); i++) {int postion = people[i][1];list<vector<int>>::iterator it = que.begin();while (postion--) {it++;}que.insert(it, people[i]);}return vector<vector<int>>(que.begin(), que.end());}
};