Description
Given a set of distinct integers, nums, return all possible subsets (the power set).
Note: The solution set must not contain duplicate subsets.
Example:
1 | Input: nums = [1,2,3] |
解法
这道题与之前combination那题基本解法一样,采用深度优先遍历,用开始参数向后搜索确保不重复,注意搜索完成后的回溯。
具体代码如下:
1 | class Solution { |