• Cours
  • Compilateur de code
  • Discuter
  • Tarification
  • Équipes
Menu
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

pythonrecursiondynamicpython3programmingbacktrackingtabulation
2nd Sep 2022, 9:04 PM
Meghraj
Meghraj - avatar
1 Réponse
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
25th Aug 2023, 7:02 PM
Han Tong
Han Tong - avatar

Vous avez souvent des questions comme celle-ci ?

Apprenez de maniĂšre plus efficace, gratuitement :

  • Introduction Ă  Python

    7.1M apprenants

  • Introduction Ă  Java

    4.7M apprenants

  • Introduction Ă  C

    1.5M apprenants

  • Introduction Ă  HTML

    7.5M apprenants

Voir tous les cours
Aujourd'hui en vedette
Hey I've done the C# and SQL beginner and intermediate, but still feel like there could be more... Is there advanced somewhere?
1 Votes
How create a new language ?
1 Votes
Beginner question
0 Votes
Is there any debugging practice here or not?
2 Votes
Can I make coding projects here and run them without sololearn pro, only in sololearn.
0 Votes
Issue with Sololearn Module Quiz Despite Correct Answers
1 Votes
I need help to solve this
0 Votes
Hey what the research process order for them that I am telling you please order them and tell me answer
0 Votes
Project
0 Votes
by getting subscription will it help to me be a pro in python is it appropriate app? please guide me
0 Votes