13 lines
386 B
Python
13 lines
386 B
Python
|
class Solution:
|
||
|
def combine(self, n: int, k: int) -> List[List[int]]:
|
||
|
rlt = []
|
||
|
def comb(l, cur, k):
|
||
|
if k == 0:
|
||
|
rlt.append(l)
|
||
|
return
|
||
|
for i in range(cur, n + 1):
|
||
|
tmp_l = l.copy()
|
||
|
tmp_l.append(i)
|
||
|
comb(tmp_l, i + 1, k - 1)
|
||
|
comb([], 1, k)
|
||
|
return rlt
|