File tree 2 files changed +36
-1
lines changed
2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 47
47
git submodule update --recursive --remote
48
48
else
49
49
echo "Submodule not found. Adding..."
50
- git submodule add https://github.com/Zanger67/Leetcode-Progress-Tracker .git '.readme_updater'
50
+ git submodule add https://github.com/Zanger67/WikiLeet .git '.readme_updater'
51
51
git submodule update --init --recursive
52
52
fi
53
53
Original file line number Diff line number Diff line change
1
+ class Solution :
2
+ def combinationSum (self , candidates : List [int ], target : int ) -> List [List [int ]]:
3
+
4
+ def combos (outputs : List [List [int ]],
5
+ current : List [int ] = [],
6
+ currentSum : int = 0 ,
7
+ candidates : List [int ] = candidates ) -> None :
8
+ if currentSum > target :
9
+ return
10
+ if currentSum == target :
11
+ outputs .append (current .copy ())
12
+ return
13
+ if not candidates :
14
+ return
15
+
16
+ hold = candidates .pop ()
17
+ combos (outputs , current , currentSum , candidates )
18
+ currentSum += hold
19
+ cnt = 0
20
+
21
+ while currentSum <= target :
22
+ current .append (hold )
23
+ cnt += 1
24
+ combos (outputs , current , currentSum , candidates )
25
+ currentSum += hold
26
+
27
+ for _ in range (cnt ) :
28
+ current .pop ()
29
+ candidates .append (hold )
30
+
31
+ candidates .sort ()
32
+ output = []
33
+ combos (output )
34
+
35
+ return output
You can’t perform that action at this time.
0 commit comments