This appears to be a nonlinear programming problem. I haven't studied
NLP, so I don't know if there are any decent algorithms for this sort
of thing. Here is a not-completely-inefficient algorithm :
Find the best deal for the last card in your list, ignoring shipping
costs. Find the best deal
Can you use some sort of hash table to store all elements of the first
list, then check whether it contains each element of the second ? This
might be O(n) in most cases.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Your replies indicate a misunderstanding of asymptotic notation. If
you do several things in a row, to get the asymptotic performance, you
take the worst performer's speed and use that.
For instance, with the hash, you do several things in a row :
Create the hash: O(n)
Fill the hash: O(n)
Because there are infinite integers, there is no need for a list of
4,300,000,000 of them to contain a duplicate. If there are
4,299,999,999 choices, there will be one duplicate. Because the
solution uses binary search, the list is sorted.
So, the full problem is probably something like the
Radix sort.