Created
December 22, 2020 12:16
-
-
Save manojnaidu619/d6844c767101e8255e487600d4b3f1fe to your computer and use it in GitHub Desktop.
Revisions
-
manojnaidu619 revised this gist
Dec 22, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ function subset(nums) { } function dfs(index, path, nums, res) { res.push([...path]) for (var i = index; i < nums.length; i += 1){ path.push(nums[i]); dfs(i + 1, path, nums, res) -
manojnaidu619 created this gist
Dec 22, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ function subset(nums) { var result = []; dfs(0, [], nums, result); console.log(result); } function dfs(index, path, nums, res) { if(path.length === 2) res.push([...path]) for (var i = index; i < nums.length; i += 1){ path.push(nums[i]); dfs(i + 1, path, nums, res) path.pop(); } } subset([1,2,3,4]);