My code is working fine on code blocks and gives correct answer but while running on coding blocks it shows ** stack smashing detected ** error .please help . code link : https://ide.codingblocks.com/s/107501
Algo++ : 0-N knapsack
Hi Aman
You are probably getting this error because you are accessing your dp array out of bound
You are making it to be dp[n+1], running loop from 1 to sum, and using dp[i-1], remember sum can be greater than n. Try revising your approach and debug your code accordingly