Grokking Oracle Coding Interview
Ask Author
Back to course home

0% completed

Solution: Single Element in a Sorted Array

Problem Statement

Given a sorted integer array nums in which each element appears exactly twice, and only 1 element appears exactly once, return the single element that appears only once.

Note: You must solve the problem in O(log n) time and O(1) space.

Examples

  1. Example 1:

    • Input: nums = [4,4,6,6,10,11,11]
    • Expected Output: 10
    • Justification: Here, 10 is the only number that doesn't have a pair.
  2. Example 2:

    • Input: nums = [1,1,2,3,3,4,4]
    • Expected Output: 2

.....

.....

.....

Like the course? Get enrolled and start learning!