Question DSA-REC-0017
HardWhat is the output of this code?
def comb(c, t, start=0, cur=[]):
if t == 0:
return [cur]
out = []
for i in range(start, len(c)):
if c[i] <= t:
out += comb(c, t - c[i], i, cur + [c[i]])
return out
print(comb([2, 3, 6, 7], 7))
- A.
[[2, 2, 3]]
- B.
[[2, 2, 3], [7]]
- C.
Sign up free to see the answer and a step-by-step explanation.