给定一个数组,返回这个数组的所有子数组

import java.util.*;
public class Solution {
    public ArrayList> subsets(int[] S) {
          ArrayList> result=new ArrayList>();
        Arrays.sort(S);
        ArrayList subList=new ArrayList();
        for (int i=0;i<=S.length;i++){
            func(S,i,0,subList,result);
        }
        return result;
         
    }
    public void func(int[] S,int num,int index,ArrayList subList,ArrayList> result){
        if (num<0){
            return;
        }else if (num==0){
            result.add(new ArrayList(subList));
        }else {
            for (int j=index;j

你可能感兴趣的:(给定一个数组,返回这个数组的所有子数组)