leetcode/77-240602-pass/main.py
2024-06-02 21:23:00 +02:00

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