#include "leetcode.h" class Solution { public: vector> reconstructQueue(vector> &people) { sort(people.begin(), people.end(), cmp); vector> ans; for (int i = 0; i < people.size(); i++) ans.insert(ans.begin() + people[i][1], people[i]); return ans; } private: static bool cmp(vector &p1, vector &p2) { if (p1[0] != p2[0]) return p1[0] > p2[0]; else return p1[1] < p2[1]; } };