Question: Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given

Given an array of ints, is it possible to choose a group of some of the ints, such that the group sums to the given target with this additional constraint: If a value in the array is chosen to be in the group, the value immediately following it in the array must not be chosen. No loops needed.

write a program to test your function

int d[] = {2, 5, 10, 4};

groupNoAdj(0,y, 4, 12) --> true

groupNoAdj(0, y, 4, 14) --> false

groupNoAdj(0, y, 4, 7) --> false

int f[] = {10, 2, 2, 3, 3};

groupNoAdj(0, f, 5, 15) --> ???

groupNoAdj(0, f, 5, 7) --> ???

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!