[C++] Binary Search
\tclass Solution {\n\t\tprivate:\n\n\t\t\tint solve(int n,vector &nums){\n\n\t\t\t\tvector ans;\n\t\t\t\tans.push_back(nums[0]);\n\n\t\t\t\tfor(int i = 1; i < n
\tclass Solution {\n\t\tprivate:\n\n\t\t\tint solve(int n,vector<int> &nums){\n\n\t\t\t\tvector<int> ans;\n\t\t\t\tans.push_back(nums[0]);\n\n\t\t\t\tfor(int i = 1; i < n; i++){\n\t\t\t\t\tif(nums[i] > ans.back()){\n\t\t\t\t\t\tans.push_back(nums[i]);\n\t\t\t\t\t}else{\n\t\t\t\t\t\tint index = lower_bound(ans.begin(),ans.end(),nums[i]) - ans.begin();\n\t\t\t\t\t\tans[index] = nums[i];\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn ans.size();\n\n\t\t\t}\n\tpublic:\n\t\tint maxEnvelopes(vector<vector<int>>& envelopes) {\n\n\t\t\tint n = envelopes.size();\n\n\t\t\tif(n == 0) return 0;\n\n\t\t\tsort(envelopes.begin(),envelopes.end(),[](vector<int> &a, vector<int> &b){\n\t\t\t\tif(a[0] == b[0]){   \n\t\t\t\t\treturn a[1] > b[1];\n\t\t\t\t}\n\t\t\t\treturn a[0] < b[0];\n\t\t\t});\n\n\n\t\t\tvector<int> nums;\n\n\t\t\tfor(int i = 0; i < n; i++){\n\t\t\t\tnums.push_back(envelopes[i][1]);\n\t\t\t}\n\n\t\t\treturn solve(n,nums);\n\t\t}\n\t};
['Dynamic Programming', 'C', 'Sorting', 'C++']