File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

algorithm in java

Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

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.




When The Going Gets Tougher,The Tougher gets Going
Deepak Lal
Ranch Hand

Joined: Jul 01, 2008
Posts: 507

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

Regards
Deepak Lal
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40061
    
  28
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: http://aspose.com/file-tools
 
subject: algorithm in java