← Practice · Backtracking
Subsets Medium
Given an array of distinct integers nums, return all possible subsets (the power set). The answer must not contain duplicate subsets and may be in any order.
Examples
nums = [1,2] -> [[],[1],[2],[1,2]]nums = [0] -> [[],[0]]
Define a function named subsets in JavaScript.
00:00▶ Visualize
JavaScript · Tab indents · Ctrl/⌘+Enter runs the tests