# algorithm in java

Problem Statement :: In Java ,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 there are numbers in the array that are adjacent and the identical value, they must either all be chosen, or none of them chosen. For example, with the array {1, 2, 2, 2, 5, 2}, either all three 2's in the middle must be chosen or not, all as a group. (one loop can be used to find the extent of the identical values).

I have done some initial Analysis and the partial code is at http://ideone.com/Lik4l/Code

please provide me with the code fix.

output is showing wrongly as,

======================

Add similar number --> 8

modified Array is 2

modified Array is 8

modified Array is 4

The flag is -->true

======================

Expected Modified Array should be {2,8,0,8}

could you help me to solve this.

I have done some initial Analysis and the partial code is at http://ideone.com/Lik4l/Code

please provide me with the code fix.

output is showing wrongly as,

======================

Add similar number --> 8

modified Array is 2

modified Array is 8

modified Array is 4

The flag is -->true

======================

Expected Modified Array should be {2,8,0,8}

could you help me to solve this.

When The Going Gets Tougher,The Tougher gets Going