O77
Single Element in a Sorted Array
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]) -> intInput & 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çerExample Execution Walkthrough
sayilar = [1, 1, 2, 3, 3, 4, 4, 8, 8] -> tekil eleman: 2Example Test Scenarios (3)
Example 1
Input:
[[1,1,2,3,3,4,4,8,8]]Expected Output:
2Example 2
Input:
[[3,3,7,7,10,11,11]]Expected Output:
10Example 3: Single Element
Input:
[[1]]Expected Output:
1