Yes, you can use sorting to reduce complexity to O(log n) by doing a binary search.
Since the array is sorted, before the missing element, each value occupies the spots 2*k and 2*k+1 in the array (subject to indexing based on 0).
So, you go to the middle of the array, say index h and check index h+1 if h is equal, or h-1 if h is odd. If the missing element arrives later, the values ββin these positions are equal, if they are earlier, the values ββare different. Repeat until a missing item is found.
Daniel Fischer
source share