Find All Numbers Disappeared in an Array
Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.
Follow up: Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.
Example 1
Input
nums = [4,3,2,7,8,2,3,1]Output
[5,6]The numbers 5 and 6 are the integers in the range [1, 8] that do not appear in nums.
Example 2
Input
nums = [1,1]Output
[2]The number 2 is the only integer in the range [1, 2] that does not appear in nums.
Constraints
- n == nums.length
- 1 <= n <= 10^5
- 1 <= nums[i] <= n