Find Missing Number
Logic Building: Rotations & Sets DSA practice problem on Onlearn.
Difficulty: easy.
Topics: Find the missing number between 1 and N in an array of size N-1 containing numbers from 1 to N, Arrays, Loops, Hashing, Frequency Counting, Time Complexity, Space Complexity, Big O Notation, Basic Arithmetic, Mathematical Algorithms, XOR, bit manipulation, complexity analysis, mathematical concepts, hashing, search algorithms, Summation Formulas, Bitwise XOR.
Missing Number Problem Statement Given an integer N and an array A of size N 1 containing N 1 distinct numbers in the range [1, N]. Find the number, between 1 to N, that is not present in the given array. Input Specification The first line contains an integer N. The second line contains N 1 space separated integers representing the elements of array A. Output Specification Print the missing number. Constraints 1 <= N <= 10^5 1 <= A[i] <= N All elements in A are distinct. Sample Test Cases Example 1: Input: Output: Explanation: In the given array, number 3 is missing. Example 2: Input: Output: Explanation: In the given array, number 2 is missing.