// Given a set of distinct integers, nums, return all possible subsets.

// Note:
// Elements in a subset must be in non-descending order.
// The solution set must not contain duplicate subsets.

// For example,
// If nums = [1,2,3], a solution is:
// [
//   [3],
//   [1],
//   [2],
//   [1,2,3],
//   [1,3],
//   [2,3],
//   [1,2],
//   []
// ]


var subsets = function(nums) {
    var result = [];
    function helper(set, i){
        if (nums.length === i){
            result.push(set);
            return;
        }
        helper(set, Number(i+1));
        helper(set + nums[i], Number(i+1));
    }
    helper([],0);
    return result;
};

@@ -639,8 +639,576 @@
 ult;%0A%7D;%0A
+%0A%0AQ: Given an array of characters, print all possible combinations. For example given a, b, c, print%0Aa%0Ab%0Ac%0Aab%0Aac%0Aabc%0Abc%0A%0A%0A%0Avar combination = function(array)%7B%0A    var str = array.join(%22%22);%0A%0A    function helper(string)%7B%0A        if (set.length === 0)%7B%0A            return %5B%22%22%5D%0A        %7D%0A        else%7B%0A          var last = str%5Bstring.length-1%5D%0A          var sub = helper(str.slice(0, -1));%0A          var joined = sub.map(function(character)%7B%0A              return character + last;%0A          %7D)%0A          return sub.concat(joined)%0A        %7D%0A    %7D%0A%0A    return helper(str)%0A%7D%0A%0A

add solution"