From e15beb5f14f212e2ffe24bedba1e5ae30fdcaba7 Mon Sep 17 00:00:00 2001 From: jiecheney <89916583+JakeVander@users.noreply.github.com> Date: Thu, 14 Jul 2022 10:41:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=200090.=E5=AD=90=E9=9B=86II.?= =?UTF-8?q?md=20Python3=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +++ .idea/encodings.xml | 6 ++ .idea/inspectionProfiles/Project_Default.xml | 70 +++++++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/leetcode-master.iml | 8 +++ .idea/misc.xml | 11 +++ .idea/modules.xml | 8 +++ .idea/vagrant.xml | 7 ++ .idea/vcs.xml | 6 ++ problems/0090.子集II.md | 27 +++++++ 10 files changed, 157 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/encodings.xml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/leetcode-master.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vagrant.xml create mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..35410cac --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..c2bae49d --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 00000000..3f19e2d8 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,70 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 00000000..105ce2da --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/leetcode-master.iml b/.idea/leetcode-master.iml new file mode 100644 index 00000000..d0876a78 --- /dev/null +++ b/.idea/leetcode-master.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..8ca8e3b1 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,11 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..7c250acd --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vagrant.xml b/.idea/vagrant.xml new file mode 100644 index 00000000..a5aa7868 --- /dev/null +++ b/.idea/vagrant.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/problems/0090.子集II.md b/problems/0090.子集II.md index e85ec66d..d503846e 100644 --- a/problems/0090.子集II.md +++ b/problems/0090.子集II.md @@ -261,6 +261,33 @@ class Solution: self.path.pop() ``` +### Python3 +```python3 +class Solution: + def subsetsWithDup(self, nums: List[int]) -> List[List[int]]: + res = [] + path = [] + nums.sort() # 去重需要先对数组进行排序 + + def backtracking(nums, startIndex): + # 终止条件 + res.append(path[:]) + if startIndex == len(nums): + return + + # for循环 + for i in range(startIndex, len(nums)): + # 数层去重 + if i > startIndex and nums[i] == nums[i-1]: # 去重 + continue + path.append(nums[i]) + backtracking(nums, i+1) + path.pop() + + backtracking(nums, 0) + return res +``` + ### Go ```Go