Here is the java code:
public class allCombinationsSumIsN {
public static void main(String args[]) {
int array[] = {7,2,3,1,-5,8,15};
int sum=10;
Set hashSet = new HashSet();
for (int i: array) {
if (hashSet.contains(i)) {
System.out.println(i+","+(sum-i));
}
else {
hashSet.add(sum-i);
}
}
}
}
On Mon, Jun 21, 2010 at 9:22 PM, sharad <[email protected]> wrote:
> How will you find all the combination of number whose sum is n
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>
--
cheers
Jeeva
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.