0
Help me in spotting the bug in this code
This is a famous GFG problem : https://www.geeksforgeeks.org/subset-sum-problem-dp-25/ I am using the right algorithm but I can't figure out where the code is failing. Code : https://code.sololearn.com/cCLZfsUYoedu/?ref=app
1 Answer
0
instead of
dp = [[0]*(k+1)]*(n+1)
replace by this
dp = [[0 for _ in range(k+1)] for _ in range(n+1)]
hope it helps