Search⌘ K
AI Features

Single Element in a Sorted Array

Explore how to find a single element that appears only once in a sorted array where every other element appears twice. Learn to apply modified binary search effectively, achieving a time complexity of O(log n) and constant space usage, while understanding the problem constraints and implementing the solution confidently.

Statement

You are given a sorted array of integers, nums, where all integers appear twice except for one. Your task is to find and return the single integer that appears only once.

The solution should have a time complexity of O(logn)O(\log n) or better and a space complexity of ...