her209
No Lifer
The best you can do with the added extra check is still 2n compares.Originally posted by: Matthias99
I already posted pseudocode for getting around this problem above. Maintain a sorted list rather than an array, so that if the new element is larger than everything already in the sorted list, it's O(1) to add it. 😛