diff --git a/problems/0078.子集.md b/problems/0078.子集.md index 8c68843d..5054246f 100644 --- a/problems/0078.子集.md +++ b/problems/0078.子集.md @@ -184,7 +184,24 @@ Python: Go: +Javascript: +```Javascript +var subsets = function(nums) { + let result = [] + let path = [] + function backtracking(startIndex) { + result.push(path.slice()) + for(let i = startIndex; i < nums.length; i++) { + path.push(nums[i]) + backtracking(i + 1) + path.pop() + } + } + backtracking(0) + return result +}; +``` -----------------------