Meaningless Drivel is fun!
The moose likes Java in General and the fly likes algorithm in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "algorithm in java" Watch "algorithm in java" New topic

algorithm in java

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

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
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
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 561

Hi Ranchers,
Could you help me with this problem???

Deepak Lal
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
You don't need code for such a problem. You need to write out with a pencil and paper exactly how you intend to solve it.
I agree. Here's the link:
subject: algorithm in java
It's not a secret anymore!