Solution: Missing Number
Explore this lesson to understand how to identify a missing number in an array of distinct integers using the cyclic sort technique. Learn to implement an efficient O(n) time complexity algorithm that sorts elements in-place and detects the first index mismatch to find the missing number, optimizing both time and space complexity.
Statement
Given an array, nums, containing distinct numbers in the range , return the only number in the range that is missing from the array.
Constraints:
-
nums.length