C++ || LIS || Binary Search || with detailed comments
c++\nclass Solution {\npublic:\n    static bool my_comp(vector<int> &a, vector<int> &b){\n        if (a[0] == b[0]) {\n            return (a[1] > b[1]);\n      
```c++\nclass Solution {\npublic:\n    static bool my_comp(vector<int> &a, vector<int> &b){\n        if (a[0] == b[0]) {\n            return (a[1] > b[1]);\n        }\n        return a[0] < b[0];\n    }\n    \n    int maxEnvelopes(vector<vector<int>>& envelopes) {\n        /* Sort envelopes in increasing order of width and decreasing order of height.\n        *  Then, apply LIS on heights.\n        *    LIS:\n        *    Create a tmp_arr to save sequence.\n        *    If curr_elem in arr is greater than tmp_arr.back(), append curr_elem to tmp_arr.\n        *    Else, replace elem in tmp_arr such that,\n        *      curr_elem < tmp_elem and it should not break incerasing nature of tmp_arr.\n        *      (Binary search for curr_elem in tmp_arr will give you the proper index)\n        *    Finally return len of tmp_arr.\n        */\n        \n        sort(envelopes.begin(), envelopes.end(), my_comp);\n\n        vector<int> tmp;\n        tmp.push_back(envelopes[0][1]);\n        for (int i = 1; i < envelopes.size(); i++){\n            int curr_elem = envelopes[i][1];\n            if (tmp.back() < curr_elem)\n            {\n                tmp.push_back(curr_elem);\n            }\n            else \n            {\n                int idx = lower_bound(tmp.begin(), tmp.end(), curr_elem) - tmp.begin();\n                tmp[idx] = curr_elem;\n            }\n            \n        }\n        return tmp.size();\n    }\n};\n```
['C']