Two Non Repeating Elements in Array Using XOR
📖 Scenario: Imagine you have a list of numbers where every number appears twice except for two unique numbers that appear only once. You want to find those two unique numbers efficiently.
🎯 Goal: Build a program that finds the two numbers that appear only once in an array where all other numbers appear twice, using the XOR operation.
📋 What You'll Learn
Create an integer array called
arr with the exact values: 2, 4, 7, 9, 2, 4Create an integer variable called
xor_all and initialize it to 0Use a
for loop with variable i to XOR all elements of arr into xor_allPrint the two unique numbers separated by a space
💡 Why This Matters
🌍 Real World
Finding unique items in data streams or logs where duplicates are common.
💼 Career
Bitwise operations and efficient algorithms are important in embedded systems, security, and performance-critical applications.
Progress0 / 4 steps
