nikunjsoni

406

Jun 28th, 2021
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Solution {
  2. public:
  3.     vector<vector<int>> reconstructQueue(vector<vector<int>>& people) {
  4.         auto comp = [](const vector<int>& p1, const vector<int>& p2)
  5.                         { return p1[0] > p2[0] || (p1[0] == p2[0] && p1[1] < p2[1]);};
  6.         sort(people.begin(), people.end(), comp);
  7.         vector<vector<int>> res;
  8.         for(auto& p : people)
  9.             res.insert(res.begin() + p[1], p);
  10.         return res;
  11.     }
  12. };
RAW Paste Data