leetcode354+嵌套矩形数目最多,二维上的最长上升子序列Dp

https://leetcode.com/problems/russian-doll-envelopes/description/

//矩形嵌套 DP
bool cmp(paira, pairb)
{
    if(a.first==b.first) return a.second<=b.second;
    return a.first< b.first;
}
class Solution {
public:
    int maxEnvelopes(vector>& envelopes) {
        int result = 0;
        int len = envelopes.size();
        vector dp(len,1);
        sort(envelopes.begin(), envelopes.end(),cmp); //pair中的first排序
        for(int i=0; i

 

你可能感兴趣的:(Leetcode)