Given an array of integers nums containing n distinct numbers taken from 0 to n, find the one number that is missing from the array.
You must implement an algorithm that runs in O(n) time and uses O(n) space.
Example 1:
Input: nums = [3, 0, 1]
Output: 2
Example 2:
Input: nums = [9,6,4,2,3,5,7,0,1]
Output: 8
n == nums.length0 <= n <= 10^4nums = [3, 0, 1]Output2WhyThe numbers 0, 1, and 3 are present; thus, 2 is missing.nums = [9, 6, 4, 2, 3, 5, 7, 0, 1]Output8WhyThe numbers 0 to 9 are represented, missing only 8.n == nums.length0 <= n <= 10^4All numbers are distinctdef missing_number(nums: list[int]) -> int: