C++ DP Solution with O(n^2) Time complexity O(n) Space complexity
class Solution {\n    public:\n        int maxEnvelopes(vector<pair<int, int>>& envelopes) {\n            int ans = 0;\n            vector<int> dp;\n           
    class Solution {\n    public:\n        int maxEnvelopes(vector<pair<int, int>>& envelopes) {\n            int ans = 0;\n            vector<int> dp;\n            if(!envelopes.size())\n                return ans;\n            sort(envelopes.begin(), envelopes.end(), cmpfunc);\n            dp.resize(envelopes.size());\n            dp[0] = 1;\n            ans = 1;\n            for(int i = 1; i < envelopes.size(); ++ i){\n                dp[i] = 0;\n                for(int j = 0; j < i; ++ j){\n                    if(envelopes[j].first < envelopes[i].first && envelopes[j].second < envelopes[i].second)\n                        dp[i] = max(dp[i], dp[j]);\n                }\n                ++ dp[i];\n                ans = max(ans, dp[i]);\n            }\n            return ans;\n        }\n    private:\n        struct cmp{\n    \t   bool operator() (const pair<int, int> &a, const pair<int, int> &b){\n    \t        return a.first*a.second < b.first*b.second; \n    \t   }\n    \t}cmpfunc;\n    };
['Dynamic Programming', 'C++']