Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static boolean isSumOf(int[] a, int n)
- {
- return isSumOf(a, n, 0, "");
- }
- private static boolean isSumOf(int[] a, int n, int i, String res)
- {
- if(n == 0){
- System.out.println(res);
- return true;
- }
- if(i == a.length || n < 0)
- return false;
- return isSumOf(a, n - a[i], i, res + " " + a[i]) || isSumOf(a, n, i + 1, res);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement