Find All Numbers Disappeared in an Array
Easy · Array, Hash Table
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.
Example 1
Input: nums = [4,3,2,7,8,2,3,1] Output: [5,6]
Example 2
Input: nums = [1,1] Output: [2]
Constraints
- n == nums.length
- 1 <= n <= 105
- 1 <= nums[i] <= n
Starter code (python)
class Solution(object):
def findDisappearedNumbers(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
"""
Related problems
- Two Sum (Easy)
- Longest Substring Without Repeating Characters (Medium)
- Median of Two Sorted Arrays (Hard)
Previous: Add Two Numbers II · Next: Delete Node in a BST · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.