Update0078.子集,添加C#

This commit is contained in:
eeee0717
2023-12-18 09:23:42 +08:00
parent 5f485a0c15
commit 5b5a05ada5

View File

@ -443,6 +443,27 @@ object Solution {
}
}
```
### C#
```csharp
public class Solution {
public IList<IList<int>> res = new List<IList<int>>();
public IList<int> path = new List<int>();
public IList<IList<int>> Subsets(int[] nums) {
BackTracking(nums, 0);
return res;
}
public void BackTracking(int[] nums, int start){
res.Add(new List<int>(path));
if(start > nums.Length) return;
for (int i = start; i < nums.Length; i++)
{
path.Add(nums[i]);
BackTracking(nums, i + 1);
path.RemoveAt(path.Count - 1);
}
}
}
```
<p align="center">