diff --git a/CHEFINSQ.py b/CHEFINSQ.py new file mode 100644 index 0000000..2d943b9 --- /dev/null +++ b/CHEFINSQ.py @@ -0,0 +1,30 @@ +#function to call recursive function and return the final solution to it's caller function +def count_sets_dp(arr,total,n,k): + mem={} + return dp(arr,total,n-1,mem,k) + +#recursive and dynamic programming function to generate subsequences and find the eligible subsequence +def dp(arr,total,i,mem,k): + key=str(total)+':'+str(k)+':'+str(i) + if key in mem: + return mem[key] + if total==0 and k==0: + return 1 + elif total<0 or k<0: + return 0 + elif i<0: + return 0 + elif total