Q78. Subsets
直达: https://leetcode.com/problems/subsets/description/
Given a set ofdistinctintegers,nums, return all possible subsets (the power set).
Note: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],
[]
]分析
求子集是递归的典型题目之一,每次向路径中添加一个数即可。
C++代码
Last updated
Was this helpful?