Question DSA-DP-0017
HardWhat is the output of this code?
a, t = [3, 34, 4, 12, 5, 2], 9
dp = [True] + [False] * t
for x in a:
for s in range(t, x - 1, -1):
dp[s] = dp[s] or dp[s - x]
print(dp[t])
- A.
Error
- B.
None
- C.
Sign up free to see the answer and a step-by-step explanation.