给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。
解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。

java
class Solution {
public List<List<Integer>> subsets(int[] nums) {
List<List<Integer>> res = new ArrayList<List<Integer>>();
for ( int i = 0; i < (1<<nums.length); i++) {
List<Integer> sub = new ArrayList<Integer>();
for ( int j = 0; j<nums.length; j++) {
if (((i>>j) & 1) == 1) {
sub.add(nums[j]);
}
}
res.add(sub);
}
return res;
}
}
