import java.util.*;
public class Solution { public ArrayList<ArrayList> subsets(int[] S) { int n=S.length; ArrayList<ArrayList>ans=new ArrayList<>(); ans.add(new ArrayList()); for(int i=0;i<n;++i){ int size=ans.size(); for(int j=0;j<size;++j){ ArrayListpath=new ArrayList(); path.addAll(ans.get(j)); path.add(S[i]); ans.add(path); } } return ans; } }