Given a collection of numbers, return all possible subclasses.
public class Solution {
public List<List<Integer>> permute(int[] num) {
ArrayList<List<Integer>> result = new ArrayList<List<Integer>>();
ArrayList<Integer> row = null;
if(num == null ||num.length == 0) return result;
long size = (long)Math.pow(2, num.length);
for(long i = 0; i < size; i ++){
row = new ArrayList<Integer>();
for(int j = 0; j < num.length; j ++){
if((i >> j) % 2 == 1) row.add(num[j]);
}
result.add(row);
}
return result;
}
}