What i understood from all lis solution
\n// this is nlogn lis variant\nwe need to sort the weights in increasing order but if they are equal then\n   heights should be in decreasing order , this is d
\n// this is nlogn lis variant\nwe need to sort the weights in increasing order but if they are equal then\n   heights should be in decreasing order , this is done to ensure that when we\n   do lis on the height the lower one do not gets picked up. eg\n   \n   [[5,4],[6,5],[6,7],[2,3]]\n   \n   after sorting in inc width and height for same width\n   \n   [[2,3] [5,4] [6,5] [6,7]]\n   \n   { 3, 4, 5, 7} this is telling we can put 3rd envolope in 4th but its false\n   so thats why we do reverse sort for same width\n   \n   [[2,3] [5,4] [6,7] [6,5]]\n   {3,4,7} {3,4,5} this wont allow lower value to be part of lis as big is ahead\n   \n\n    // time = nlogn\n\n```\n    bool static comp(vector<int> &a, vector<int> &b){\n        if(a[0] == b[0]){\n            return a[1] > b[1];\n        }\n        return a[0] < b[0];\n    }\n    int maxEnvelopes(vector<vector<int>>& envelopes) {\n        sort(envelopes.begin(),envelopes.end(),comp);\n        vector<int> temp;\n        temp.push_back(envelopes[0][1]);\n        for(int i=1; i<envelopes.size(); ++i){\n            if(temp.back() < envelopes[i][1]){\n                temp.push_back(envelopes[i][1]);\n            }else{\n                int idx = lower_bound(temp.begin(),temp.end(),envelopes[i][1])\n                    - temp.begin();\n                temp[idx] = envelopes[i][1];\n            }\n        }\n        return temp.size();\n    }\n```
['Dynamic Programming']