id/email
password
forgot password
about | help | done | prefs | create account
CodingBat code practice

Java > Recursion-2 > groupNoAdj
prev  |  next  |  chance

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.)

groupNoAdj(0, {2, 5, 10, 4}, 12) → true
groupNoAdj(0, {2, 5, 10, 4}, 14) → false
groupNoAdj(0, {2, 5, 10, 4}, 7) → false

...Save, Compile, Run

See also Java Example Code. Java help docs: If Boolean Logic | Strings | While and For Loops | Arrays and Loops


prev  |  next  |  chance   |  CodingBat  >  Recursion-2

Forget It! -- delete my code for this problem 409.0

Copyright Nick Parlante 2006-10 - privacy