4 line of code in c++ using dp
```\n// please upvote if you like it\nclass Solution {\npublic:\n    int maxEnvelopes(vector>& E) {\n        sort(E.begin(), E.end(),  \n             -> bool {r
```\n// please upvote if you like it\nclass Solution {\npublic:\n    int maxEnvelopes(vector<vector<int>>& E) {\n        sort(E.begin(), E.end(), [](vector<int>& a, vector<int>& b) \n             -> bool {return a[0] == b[0] ? b[1] < a[1] : a[0] < b[0];});\n        vector<int> dp;\n        for (auto& env : E) {\n            int height = env[1];\n            int left = lower_bound(dp.begin(), dp.end(), height) - dp.begin();\n            if (left == dp.size()) dp.push_back(height);\n            dp[left] = height;\n        }\n        return dp.size();\n    }\n};
['Dynamic Programming']