Getting wrong output


please check my code, and please tell me how to correct it

Hey @shivamgoel150 instead of using dp[i-1][w[i-1]-j]+p[i-1] you have to use dp[i-1][j-w[i-1]]+p[i-1]
in your code and if(i==0 || j==0) dp[i][j] =0 ; and after this statement you have another if statement so instead of that if statement use else if because there might me cases where i==0 and it is going into the next if statement and thereby causing runtime error. (index out of bounds)

Hope it helps :blush: .
If your doubt is now resolved please mark it as resolved and rate me accordingly .
Else you can further questions here .
Thankyou