Given a set of numbers [1-N]. Subsets such that the sum of numbers in the subset is a prime number.
Problem Given a set of numbers [1-N] . Find the number of subsets such that the sum of numbers in the subset is a prime number.
Solution Method 1 - Using DP
Maximum sum can be = N*(N+1) / 2 for any subset considered, as numbers are from 1 to N.
Hence put S = (N*(N+1) / 2) in subset sum problem.
For each number in the Sum S, check if there is subset of numbers from 1 to N that sum up to S - Yes that you can do with Subset Sum problem.
[Read More]