Single Element in a Sorted Array
Learning 1D Array Binary Search DSA practice problem on Onlearn.
Difficulty: easy.
Topics: Find the single number in an array where every other number appears twice, Arrays, Binary Search, XOR, Time Complexity, Space Complexity, Bitwise Operations, Linear Search, bit manipulation, edge cases, brute force, binary search, time complexity analysis, Brute-Force Search.
Problem Statement You are given a non empty array of integers where every element appears exactly twice, except for one element which appears only once. All duplicate elements are guaranteed to appear consecutively. Your task is to find that single, unique element. Input Specification The input consists of a single line containing space separated integers, representing the elements of the array arr. Output Specification Print the single non duplicate integer found in the array. Constraints The array will have an odd length. Every number except one appears exactly twice. Duplicate numbers appear consecutively. Example 1 Input: Output: Explanation: Only the number 4 appears once in the array. Example 2 Input: Output: Explanation: Only the number 3 appears once in the array. Difficulty: Medium