Problem with sum of seqence
Posted: Mon Apr 03, 2006 5:46 pm
There is a set of N integers in range [-1000, 1000], N< 1000
I have to find if there is any subset which sum of elements is exactly S.
S is an integer in range [-1 000 000, 1 000 000 ]
Example:
Set - {5, 10, 25, 50}
S = 30
I can find a subset {5,25} - 5+25 = 30
Set - { -6,9,100,-45}
S = -42
I can find a subset {-6,9,-45} - (-6)+9+(-45) = 3 + (-45) = (-42)
Set - {-5, 10, 20, 100}
Set = 3
I can't find any set which sum is exacly 3.
Please help
I have to find if there is any subset which sum of elements is exactly S.
S is an integer in range [-1 000 000, 1 000 000 ]
Example:
Set - {5, 10, 25, 50}
S = 30
I can find a subset {5,25} - 5+25 = 30
Set - { -6,9,100,-45}
S = -42
I can find a subset {-6,9,-45} - (-6)+9+(-45) = 3 + (-45) = (-42)
Set - {-5, 10, 20, 100}
Set = 3
I can't find any set which sum is exacly 3.
Please help
