題目
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.
給定一個包含n個整數的陣列nums,其中nums[i]的範圍為[1, n],返回一個陣列,其中包含範圍[1, n]內未在nums中出現的所有整數。
Example 1
1 | Input: nums = [4,3,2,7,8,2,3,1] |
Example 2
1 | Input: nums = [1,1] |
Constraints:
- n == nums.length
- 1 <= n <= 105
- 1 <= nums[i] <= n
我的解題
1 | class Solution { |