From 5b5a05ada59333813312ebfe2f3f258cb9ea791f Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Mon, 18 Dec 2023 09:23:42 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Update0078.=E5=AD=90=E9=9B=86=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/0078.子集.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/problems/0078.子集.md b/problems/0078.子集.md index 5f3654de..06547e3d 100644 --- a/problems/0078.子集.md +++ b/problems/0078.子集.md @@ -443,6 +443,27 @@ object Solution { } } ``` +### C# +```csharp +public class Solution { + public IList> res = new List>(); + public IList path = new List(); + public IList> Subsets(int[] nums) { + BackTracking(nums, 0); + return res; + } + public void BackTracking(int[] nums, int start){ + res.Add(new List(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); + } + } +} +```

From 7fdb7b17024bbfd7636dbc8100acb1687445b40b Mon Sep 17 00:00:00 2001 From: eeee0717 Date: Tue, 19 Dec 2023 09:32:06 +0800 Subject: [PATCH 2/2] =?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); + } + } +} +```