Solution: Missing Number
Explore how to apply cyclic sort to find the missing number in an array containing distinct integers in the range [0, n]. Understand the step-by-step process to sort elements in place and identify the first mismatch between element values and their indices, resulting in a time-efficient and space-optimized solution.
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