Ice Cream Parlor

  • + 1 comment

    That is correct -- but you can perform two linear searches and throw out the first hit of the second search if and when it matches the result of the first search. Alternatively, one may search from back to front.

    Since the original order is to be kept, I am unaware of alternatives to linear search. By using the two-pointer technique, I arrive at O(nlogn + n + n) = O(nlogn).