Find the single missing number in an array containing numbers from 1 to n using XOR.
Difficulty: Hard
Phase: 6 · Mixed Logical Challenges
XP Reward: 30 XP
Topics: Mixed Logical Challenges, Hard
Supported Languages: Python, JavaScript, C, C++, Java
Problem Description
Given array of N-1 integers from range 1 to N, find the single missing number using bitwise XOR. Input Format: Read input from standard input (stdin). Output Format: Print the result to standard output (stdout).
Constraints
- -10^9 <= N <= 10^9
Examples
Example 1
Input: 4 1 2 4
Output: 3
Explanation: Sample execution for input 4 1 2 4