C++ | Simple binary search solution
Note : Sort hight in decreasing order when width is same.\n\nclass Solution {\npublic:\n    int bSearch(vector<int>& vec, int maxVal, vector<vector<int>>& envel
**Note :** Sort `hight` in decreasing order when `width` is same.\n```\nclass Solution {\npublic:\n    int bSearch(vector<int>& vec, int maxVal, vector<vector<int>>& envelopes, int i){\n        int l = 0;\n        int r = maxVal;\n        \n        int temp = maxVal;\n        \n        while(l <= r){\n            int mid = l + (r - l) / 2;\n            \n            if(vec[mid] < envelopes[i][1])\n                l = mid + 1;\n            \n            else {\n                temp = mid;\n                r = mid - 1;\n            }\n        }\n        \n        return temp;\n    }\n    \n    // to sort in decreasing order\n    static bool decSort(vector<int>& v1, vector<int>& v2) {\n        if(v1[0] == v2[0])\n            return v1[1] > v2[1];\n        \n        return v1[0] < v2[0];\n    }\n    \n    int maxEnvelopes(vector<vector<int>>& envelopes) {\n        int siz = envelopes.size();\n        \n        if(siz == 0)\n            return 0;\n        \n        sort(envelopes.begin(), envelopes.end(), decSort);\n        \n        vector<int> vec(siz, 0);\n        int maxVal = 0;\n        \n        for(int i = 0; i < siz; i++) {\n            int pos = bSearch(vec, maxVal, envelopes, i);\n            \n            vec[pos] = envelopes[i][1];\n            \n            if(pos == maxVal)\n                maxVal++;\n        }\n        \n        return maxVal;\n    }\n};\n```
['Dynamic Programming', 'C', 'Binary Tree', 'C++']