Sunday, November 30, 2014

Subsets 2

Problem

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

Note:
Elements in a subset must be in non-descending order.
The solution set must not contain duplicate subsets.
For example,

Idea

把S排序,然后通过判断S[i]!=S[i-1]去掉重复
递归的方法求解.每次插入tmp,就把tmp加到result中.

Solution


No comments:

Post a Comment