From 7fdb7b17024bbfd7636dbc8100acb1687445b40b Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Tue, 19 Dec 2023 09:32:06 +0800 Subject: [PATCH] =?UTF-8?q?Update0090.=E5=AD=90=E9=9B=862=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0C#?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problems/0090.子集II.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) 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); + } + } +} +```