C++ | Variation of LIS | DP
\nclass Solution {\n    static bool compare(vector<int>v1, vector<int>v2) {\n        return v1[0] < v2[0] || (v1[0] == v2[0] && v1[1] < v2[1]);\n    }\npublic:\
```\nclass Solution {\n    static bool compare(vector<int>v1, vector<int>v2) {\n        return v1[0] < v2[0] || (v1[0] == v2[0] && v1[1] < v2[1]);\n    }\npublic:\n    int maxEnvelopes(vector<vector<int>>& envelopes) {\n        \n        int n = envelopes.size();\n        if (n == 0) return 0;\n        \n        sort(envelopes.begin(), envelopes.end(), compare);\n        \n        int LIS[n];\n        for (int i = 0; i < n; i++)\n            LIS[i] = 1;\n        \n        int ans = 1;\n        for (int i = 0; i < n; i++) {\n            for (int j = 0; j < i; j++) {\n                if (envelopes[i][0] > envelopes[j][0] && envelopes[i][1] > envelopes[j][1])\n                    LIS[i] = max(LIS[i], 1+LIS[j]);\n            }\n            ans = max(ans, LIS[i]);\n        }\n        \n        return ans;\n    }\n};\n```
[]