Find Missing Number
Explore methods to identify the missing number in an array of positive integers from 1 to n. Understand naive, sorting-based, and optimal solutions that use the sum formula for natural numbers to achieve linear time and constant space complexity.
Statement
Given an array of positive numbers from to , such that all numbers from to are present except one number, , find . The input array is not sorted.
Example
For example, for , let’s look at the below array, that is missing ...