题目所属分类
dfs也可以二进制的求法
(i>>j&1) == 1 i的第j位是否等于1
1<<n 可以当作2 ^ n
原题链接
给你一个整数数组 nums ,数组中的元素 互不相同 。返回该数组所有可能的子集(幂集)。
解集 不能 包含重复的子集。你可以按 任意顺序 返回解集。
代码案例:输入:nums = [1,2,3]
输出:[[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]]
题解
普通的dfs 时间复杂度为2^n * n 如果不记方案就是2 ^ n
class Solution {
List<List<Integer>> ans = new ArrayList<List<Integer>>();
List<Integer> path = new ArrayList<Integer>();
public List<List