leetcode39

class Solution {
public:
    static bool cmp(const int & a,const int & b){return a> combinationSum(vector& candidates, int target) {
        map>>mp;
        mp[0] = vector>(1,vector(0));
        set>ss;
        
        for(int i = 1;i<=target;i++)
        {
            for(int j = 0;j= candidates[j])
                {
                    int res = i-candidates[j];
                    for(int k = 0;ktmp = mp[res][k];
                        tmp.push_back(candidates[j]);
                        sort(tmp.begin(),tmp.end(),cmp);
                        if(!ss.count(tmp))
                            mp[i].push_back(tmp);
                        ss.insert(tmp);
                    }
                }
            }
            
        }
        return mp[target];
    }
};

 

你可能感兴趣的:(leetcode)