언어: python3
class Solution:
def combine(self, n: int, k: int) -> List[List[int]]:
result = []
cur = []
def dfs(cur:List[int],start:int,count:int):
if count == k:
result.append(cur[:])
else:
for i in range(start,n+1):
cur.append(i)
dfs(cur,i+1,count+1)
cur.pop()
dfs(cur,1,0)
return result
'''
return list(itertools.combinations(range(1,n+1),k))
'''