MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / dfs

Method dfs

-216-Combination-Sum-III/Approach2.py:7–17  ·  view source on GitHub ↗
(i, j, l, lst)

Source from the content-addressed store, hash-verified

5 if n < k or n > 45: return []
6
7 def dfs(i, j, l, lst):
8 if j == 0 and l == k:
9 res.append(lst.copy())
10 return
11
12 if j < 0 or i > 9 or l == k: return
13
14 lst.append(i)
15 dfs(i + 1, j - i, l + 1, lst)
16 lst.pop()
17 dfs(i + 1, j, l, lst)
18
19 res = []
20 dfs(1, n, 0, [])

Callers

nothing calls this directly

Calls 1

dfsFunction · 0.50

Tested by

no test coverage detected