educative.io

Error in solution: some cases do not work!

Case1:
Input: {1, 0 }, S=1
Expected output should be: 2, but both recursive solutions gets 1!

Case2:
Input: {0, 1}, S=1
Expected output should also be: 2, but the bottom up DP solution gets 1!

Something goes wrong with the basic condition or initial values, please try to correct it. Thx, :smile:

By the way, the same error also accurs in the ‘target sum’ lesson, since the both lessons share the same solution.


Course: Grokking Dynamic Programming Patterns for Coding Interviews - Learn Interactively
Lesson: Count of Subset Sum - Grokking Dynamic Programming Patterns for Coding Interviews

1 Like

Hi @Isaack,
Thanks for contacting us with your query. We really appreciated that you have shared your thoughts with us and explained them very well. It is great seeing that you guys are always coming up with betterments. The problem set says Given a set of positive numbers, find the total number of subsets whose sum is equal to a given number ‘S’.The solution provided in the lesson assumed 0 as neutral and was not considered a positive number but you can add the number 0 as well in your solution. By the way, your feedback is much appreciated.

Happy Learning :blush: