beat 99.78% user with cpp|| LIS reference || well commented code
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n     static bool comp(vector<int> &a , vector<int> &b){\n        if(a[0] == b[0]){\n            return a[1]>b[1];\n        }\n        else{\n            return a[0]<b[0];\n        }\n        return false;\n    }\n    int maxEnvelopes(vector<vector<int>>& envelopes) {\n    /// just for fast input  and output\n         int fast_io = [](){\n        ios::sync_with_stdio(0);\n        cin.tie(0);\n        cout.tie(0);\n        return 0;\n    }(); \n\n      // just a combination of lis\n      // why beacuse in LIS - you have to maintain two \n      // things first you can only take current element \n      // if its index greater then previous taken index\n      // and second its values \n      // the first was taken care  by the property of array\n      // beacuse the indexes are always increasing when \n      // go forward in the array \n      // we can imitates this property by just sorting the \n      // element on the basis of the envelope[i][0]\n      // after sorting just care about the second paramenter envelope[i][1]\n\n\n    // there is problem when you sort index just on the basis \n    // envelope[i][0] beacause it might happen that two\n    // same envelope[i][0] .. then in simple sorting \n    // then it will go to second element and use that to find\n    // order ... but it in that case you may use same envelopes[i][0]\n    // to update the current anwser ..\n    /// this will not happen if you just reverse the order for second element\n      sort(envelopes.begin() , envelopes.end(), comp);\n     \n     // here we only care about how many no are smaller than this no \n     // by how much we don\'t care\n       vector<int> temp;\n       temp.push_back(envelopes[0][1]);\n\n       for(int i = 1 ; i< envelopes.size(); i++){\n      //  if(envelopes[i][0] == envelopes[i-1][0]) continue;\n         if(envelopes[i][1]>  temp.back()){\n            temp.push_back(envelopes[i][1]);\n         }\n         else{\n            // here some confusion may arise why are we replacing \n            // beacause we want minmum possible value at particular \n            // index-> just dry run se how it is working\n            int ind = lower_bound(temp.begin() , temp.end() , envelopes[i][1]) - temp.begin();\n            temp[ind] = envelopes[i][1];\n         }\n       }\n       return temp.size();\n\n\n\n    }\n};\n```
['C++']