# [leetcode]90. Subsets II

class Solution {
public:
vector<vector<int>> subsetsWithDup(vector<int>& nums) {
vector<int> cur;
vector<vector<int>> ret;
ret.push_back(cur);
vector<vector<int>> lastR;
vector<vector<int>>::iterator iter;

sort(nums.begin(),nums.end());//最重要的一步

for(int i=0;i<nums.size();i++)
{
lastR=ret;

for(int j=0;j<lastR.size();j++)
{
cur=lastR[j];
cur.push_back(nums[i]);
iter=find(lastR.begin(),lastR.end(),cur);

if (iter==lastR.end())
ret.push_back(cur);
}

}
return ret;
}
};

• 本文已收录于以下专栏：

## leetcode 90. Subsets II

Given a collection of integers that might contain duplicates, nums, return all possible subsets. ...

## 【leetcode】90. Subsets II

leetcode, subsets ||， 3种解法

Subsets I and II

## leetcode 90 Subsets II

leetcode 90 Subsets II c++ Python

## LeetCode 90 Subsets II

Given a collection of integers that might contain duplicates, nums, return all possible subsets. No...

## LeetCode 78, 90. Subsets i, ii

1. 题目描述 Given a set of distinct integers, nums, return all possible subsets. Note: Element...

## 【LeetCode】90. Subsets II解法及注释

90. Subsets II Total Accepted: 65104 Total Submissions: 214320 Difficulty: Medium Given a collecti...

## Leetcode 90 - Subsets II（Search）

• Lzedo
• 2017-02-17 20:51
• 111

举报原因： 您举报文章：深度学习：神经网络中的前向传播和反向传播算法推导 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)