Single Element in a Sorted Array (opens in new tab)
leetcode.com Problem Statement Given a sorted array where: Every element appears exactly twice. Only one element appears once. Find the single element in O(log N) time and O(1) space. Brute Force Intuition In an interview, you can explain it like this: Since every element appears twice except one, we can iterate through the array and count frequencies. The element with frequency 1 is our answer. This works but doesn't utilize the sorted nature of the array. Complexity Time Complexity: O(N) Sp...
Read the original article