C++ nlogn solution
class Solution {\n    public:\n        int maxEnvelopes(vector<pair<int, int>>& envelopes) {\n            auto Cmp = [](const pair<int, int> &a, const pair<int,
    class Solution {\n    public:\n        int maxEnvelopes(vector<pair<int, int>>& envelopes) {\n            auto Cmp = [](const pair<int, int> &a, const pair<int, int> &b) { \n                if(a.first < b.first) return true;\n                if(a.first == b.first && a.second > b.second) return true;\n                return false;\n            };\n            auto Cmp2 = [](const pair<int, int> &a, const pair<int, int> &b) { \n                return a.second < b.second;\n            };\n            sort(envelopes.begin(), envelopes.end(), Cmp);\n            \n            vector<pair<int, int>> res;\n            for(int i=0; i<envelopes.size(); i++) {\n                auto it = std::lower_bound(res.begin(), res.end(), envelopes[i], Cmp2);\n                if(it == res.end()) res.push_back(envelopes[i]);\n                else *it = envelopes[i];\n            }\n            return res.size();\n        }\n    };
['Binary Tree', 'C++']