human
Dynamic Programming | Returns true if there is a subset of set [ ] with sun equal to given sum.
Base Cases.
If last element is greater than sum , then ignore it.
else , check if sum can be obtained by any of the following ( a ) including the last element ( b ) excluding the last element.
Driver code"
How can the above be solved in Python?
 ... Can you provide a code to dynamic Programming and the other steps required?
assistant
#Here is code to dynamic Programming and the other steps required.
 def isSubsetSum ( set , n , sum ) :
	if ( sum == 0 ) :
		return True
	if ( n == 0 ) :
		return False
	if ( set [ n - 1 ] > sum ) :
		return isSubsetSum ( set , n - 1 , sum )
	return isSubsetSum ( set , n - 1 , sum ) or isSubsetSum ( set , n - 1 , sum - set [ n - 1 ] )
set = [ 3 , 34 , 4 , 12 , 5 , 2 ]
sum = 9
n = len ( set )
if ( isSubsetSum ( set , n , sum ) == True ) :
	print ( " Found ▁ a ▁ subset ▁ with ▁ given ▁ sum " )
else :
	print ( " No ▁ subset ▁ with ▁ given ▁ sum " )