MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / main

Method main

Java/Recursion/Subset_Sum.java:10–23  ·  view source on GitHub ↗
(String args[])

Source from the content-addressed store, hash-verified

8 return subset(arr, s - arr[i], i+1, n) + subset(arr, s ,i+1, n);
9 }
10 public static void main(String args[])
11 {
12 Scanner I = new Scanner(System.in);
13 System.out.println("Enter the number of elements you want in the array");
14 int N = I.nextInt();
15 System.out.println("Enter the elements of the array");
16 int a[] = new int[N];
17 for(int i = 0; i < N; i++)
18 a[i] = I.nextInt();
19 System.out.println("Enter the value of sum, you want to check in the array");
20 int sum = I.nextInt();
21 System.out.println("You have " + subset(a,sum,0,N) + " subsets in the array that can yield the given sum");
22 I.close();
23 }
24}

Callers

nothing calls this directly

Calls 1

subsetMethod · 0.95

Tested by

no test coverage detected