*
* @param A int整型一维数组
* @return int整型二维数组
*/
function subsets( A ) {
// write code here
if(A.length == 0) return [];
A.sort(function(a,b){return a- b;})
let res = [],tmp = [];
res.push([]);
for(let i = 1;i <= A.length;i++){
sub(A,res,tmp,0,i);
}
return res;
}
function sub( A,res,tmp,start,num ){
if(tmp.length === num){
res.push(tmp.slice());
return;
}
for(let i = start;i < A.length;i++){
tmp.push(A[i]);
sub(A,res,tmp,i + 1,num)
tmp.pop();
}
}
module.exports = {
subsets : subsets
};