I have an array of numbers nums[] and target such that it satisfies the below condition {{nums[],target}
1> {{8, 2, 2, 1},12} --> returns true
2> {{8, 2, 2, 1},9} --> returns true
1 condition> identical adjacent values with a subset of remaining numbers sum to target (or)
2 condition> identical adjacent values are not chosen such that subset of other numbers sum to target.
so that in this example
1> 8+2+2 = 12.
2> 8+1=9.
how do i handle the above 2 conditions in Java.
EDITED FOR DANTE:
Expected This Run
groupSumClump(0, {2, 4, 8}, 10) → true true OK
groupSumClump(0, {1, 2, 4, 8, 1}, 14) → true true OK
groupSumClump(0, {2, 4, 4, 8}, 14) → false false OK
groupSumClump(0, {8, 2, 2, 1}, 9) → true false X
groupSumClump(0, {8, 2, 2, 1}, 11) → false false OK
groupSumClump(0, {1}, 1) → true false X
groupSumClump(0, {9}, 1) → false false OK
other tests false X
*Code for Dante:
http://www.ideone.com/xz7ll
@Dante,Please check the above link,it fails for test scenarios mentioned.