O77

Single Element in a Sorted Array

Mid / Senior Engineer
Target Time: 25 - 35 Minutes
Type: NUMERIC

Problem Statement & Objective

You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element in O(log n).

Function Signature (Python)

single_non_duplicate(nums: list[int]) -> int

Input & Output Contract

Output Rule:Tekil elemanın değeri.

System Constraints

1 <= sayilar.length <= 10^5
-10^5 <= sayilar[i] <= 10^5
Tekil eleman dışında her eleman tam 2 kez geçer

Example Execution Walkthrough

sayilar = [1, 1, 2, 3, 3, 4, 4, 8, 8] -> tekil eleman: 2

Example Test Scenarios (3)

Example 1
Input:[[1,1,2,3,3,4,4,8,8]]
Expected Output:2
Example 2
Input:[[3,3,7,7,10,11,11]]
Expected Output:10
Example 3: Single Element
Input:[[1]]
Expected Output:1
Loading Python Editor...
Input Parameters
[
  [
    1,
    1,
    2,
    3,
    3,
    4,
    4,
    8,
    8
  ]
]
Expected Output
2