how about going through every truck and doing temp=(free_space - load);
if(temp < min && temp >=0)
{
min=temp;
truck = i;
}
now after traversing we have found the truck where we can add load.
no need of sorting....
complexity =O(n) where n is number of trucks
space complexity = constant
On Sat, Mar 10, 2012 at 10:45 PM, Bhavani Pradeep <[email protected]>wrote:
> and i guess there can be multiple input loads too... i saw the same
> question elsewhere too
>
> --
> 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.
>
--
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.