Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #39
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Aug 26, 2023
1 parent fa005d5 commit 1fb4ea4
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions content/leetcode/2023/8.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@ title: "2023.8"
draft: false
---

# 2023.8.26

```python
#
# @lc app=leetcode.cn id=39 lang=python3
#
# [39] 组合总和
#

# @lc code=start
from typing import List


class Solution:
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
res = []

def dfs(candidates, target, path):
if target == 0:
res.append(path)
return
elif target < 0:
return
else:
for i in range(len(candidates)):
dfs(candidates[i:], target - candidates[i], path + [candidates[i]])

dfs(candidates, target, [])
return res


# @lc code=end
```

# 2023.8.25

```python
Expand Down

0 comments on commit 1fb4ea4

Please sign in to comment.