[C++] - Classic DP problem variant
Variant of Classic DP - LIS problem :\nTime Complexity - O(n^2)\nSpace Complexity - O(n)\n\n\nclass Solution {\npublic:\n    int maxEnvelopes(vector<vector<int>
**Variant of Classic DP - LIS problem :**\nTime Complexity - O(n^2)\nSpace Complexity - O(n)\n\n```\nclass Solution {\npublic:\n    int maxEnvelopes(vector<vector<int>>& envelopes) {\n        sort(begin(envelopes),end(envelopes),[]\n             (const vector<int> &a,const vector<int> &b){\n                 return (a[0]==b[0] ? a[1]<b[1] : a[0]<b[0]);\n             });\n\t\t\t \n        vector<int> dp(envelopes.size(),1);\n\t\t\n        for(int i=1;i<envelopes.size();i++){\n            for(int j=0;j<i;j++){\n                if(envelopes[j][0]<envelopes[i][0]  &&  envelopes[j][1]<envelopes[i][1]){\n                    if(dp[i]<dp[j]+1)\n                        dp[i]=dp[j]+1;\n                }\n            }\n        }\n        return *max_element(begin(dp),end(dp));\n    }\n};\n```\n\nEdit1 :- It can be done in O(nlogn) as well. Will include that approach later.
['Dynamic Programming', 'C', 'C++']