Find the Number Appearing Odd Number of Times

Interview Problems DSA practice problem on Onlearn.

Difficulty: easy.

Topics: Find the number that appears an odd number of times in an array, Arrays, XOR, Bitwise Operations, Hash Map, Frequency Counting, Time Complexity, Space Complexity, Big O Notation, Loops, Data Structures, bit manipulation, frequency counting, sorting algorithms, array traversal, Sorting & Pair Checking.

Given an array of positive integers, where all elements appear an even number of times except for one element which appears an odd number of times. Your task is to find that unique element. Input Specification: The first line contains an integer N (1 <= N <= 10^5), representing the number of elements in the array. The second line contains N space separated positive integers a1, a2, ..., an (1 <= ai <= 10^9). Output Specification: Print the single integer that appears an odd number of times. Constraints: 1 <= N <= 10^5 1 <= a i <= 10^9 It is guaranteed that exactly one element appears an odd number of times. Sample Test Cases: Sample Input 1: Sample Output 1: Explanation 1: '1' appears 2 times (even) '2' appears 2 times (even) '3' appears 2 times (even) '4' appears 1 time (odd) Sample Input 2: Sample Output 2: Explanation 2: '5' appears 2 times (even) '1' appears 2 times (even) '2' appears 1 time (odd)