vector<string> res; string path; void dfs(string& nums, int start,int digit,int alpha,int m) { if (res.size() > 666666||path.size()>m) return; if(digit>=1&&alpha>=2&&path.size()==m) res.push_back(path); for (int i = start; i<nums.size(); ++i) { if (i>start&&nums[i] == nums[i - 1]) continue; path.push_back(nums[i]); if(isdigit(nums[i])) dfs(nums,i + 1,digit+1,alpha,m); else dfs(nums, i + 1, digit, alpha + 1,m); path.pop_back(); } } void subsetsWithDup(string &nums,int m) { sort(nums.begin(), nums.end()); dfs(nums, 0,0,0,m); } 刚刚少了剪枝条件,现在不知道这个能过多少
1 2

相关推荐

尊尼获获:闺蜜在哪?
点赞 评论 收藏
分享
牛客网
牛客企业服务