I'd try a tabular approach. Check dynamic programming. Samples like
LCS may give you a click.


On Tue, Mar 29, 2011 at 11:46 PM, Subhransu
<[email protected]> wrote:
> set of integers in an array X that the sum equals a given number N
>
> Eg. X = {-1, -3, 5, 13, 2, 24, 9, 3, 3}
>
> Lets say the number 5 which can be formed in the following manner 5= 2 + 3
> (the values from array). If there is no match it has to return
> invalid numbers.
>
> We also have to see the complexity of the solution.
>
> I thought of one approach but not sure if there is more approach where the
> complexity will be minimal.
> Lets say sort the array and now take number and find the closest number for
> that.
> Then in a recursion manner search for another( Lets say number '5', it
> search the list and found closest match
> will be 3. Then recursively search for 3 now where closest match is 2)
>
> Any algo with better complexity will be appreciated.
>
> Subhransu Panigrahi
>
> Email: [email protected]
>
> --
> 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.
>



-- 
Cheers,
hammett
http://hammett.castleproject.org/

-- 
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.

Reply via email to