// Define the function to solve the problemfunctionsolveUtil(ind,arr,dp,target){// Check if the result for this index is already calculatedif (dp[ind][target]){returndp[ind][target];}// Base casesif (target===0){returntrue;}if (ind===0){returnarr[ind]===target;}// Calculate the maximum value by either picking or not picking the current elementletnonPick=solveUtil(ind-1,arr,dp,target);letpick=false;pick=arr[ind]<=target?solveUtil(ind-1,arr,dp,target-arr[ind]):false;// Store the result in the DP array and return itdp[ind][target]=Math.max(pick,nonPick);returnMath.max(pick,nonPick);}// Main function to solve the problemfunctionsubsetSumToK(n,k,arr){// Initialize a DP array with -1constdp=newArray(n);for (leti=0;i<n;i++){dp[i]=newArray(k+1).fill(false);}// Call the solveUtil function with the last indexreturnsolveUtil(n-1,arr,dp,k);}// Main programfunctionmain(){constarr=[1,2,3,4];constk=10;constn=arr.length;if (subsetSumToK(n,k,arr)){console.log("Subset with given target found");}else{console.log("Subset with given target not found");}}// Call the main function to run the programmain();