to_google.
BAN USERYes; this is software and any abstractions can be derived and made available. My point was the ease of crafting code and implementation especially when objects of being interested tend to vary in sizes.
OTOH, my original response stands corrected. The reason for highlighting the last condition in the question meant to say that the age-old trick of embedding the insertion data structure into the original object would not work as it would be provide for a singular member of the original entity into stack from library aka., it does not allow the same original entity to be inserted into different stacks at the same simultaneously
Step 1: Sort the array O(nlogn)
Step 2: For each element x in the sorted array, find the complement element x+d using binary search. Before attempting step 2, ensure that the in sorted array last element value - first element value >= d.
For step 2, the worst case would be O(nlogn)
Yes; this is software and any abstractions can be derived and made available. My point was the ease of crafting code and implementation especially when objects of being interested tend to vary in sizes.
- to_google. May 22, 2012OTOH, my original response stands corrected. The reason for highlighting the last condition in the question meant to say that the age-old trick of embedding the insertion data structure into the original object would not work as it would be provide for a singular member of the original entity into stack from library aka., it does not allow the same original entity to be inserted into different stacks at the same simultaneously