Array Subset Sum LeetCode (Subset sum of an array - subset sum problem dynamic programming)

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given sum.

Example:
  • Input:  set[] = {3, 34, 4, 12, 5, 2}, sum = 9
  • Output:  True  //There is a subset (4, 5) with sum 9.


This is a popular dynamic programming problem that is also popular in GeeksForGeeks and other forums - Link 1 A collection of hundreds of interview questions and solutions are available in our blog at Interview Question Solutions

Solution:

 

No comments:

Post a Comment