diff --git a/problems/0090.子集II.md b/problems/0090.子集II.md index 13080cd9..9fc334a4 100644 --- a/problems/0090.子集II.md +++ b/problems/0090.子集II.md @@ -640,6 +640,31 @@ object Solution { } } ``` +### C# +```c# +public class Solution +{ + public IList> res = new List>(); + public IList path = new List(); + public IList> SubsetsWithDup(int[] nums) + { + Array.Sort(nums); + BackTracking(nums, 0); + return res; + } + public void BackTracking(int[] nums, int start) + { + res.Add(new List(path)); + for (int i = start; i < nums.Length; i++) + { + if (i > start && nums[i] == nums[i - 1]) continue; + path.Add(nums[i]); + BackTracking(nums, i + 1); + path.RemoveAt(path.Count - 1); + } + } +} +```