DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
DevHireLab
TutorialsBootcamp
Problems
Code SimulatorAI InterviewSoonContact
Back to Arena
easy
Array

Find All Numbers Disappeared in Array

**Problem Statement:** 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`. **Hint / Expected Approach:** Negate-index marking trick **Edge Cases to Consider:** - (1) Consecutive numbers 1–n (no missing) - (2) All same number - (3) n = 1

Examples

Example 1
Input: [4,3,2,7,8,2,3,1]
Output: [5,6]
Example 2
Input: [1,1]
Output: [2]
Example 3
Input: [1]
Output: []

Constraints

  • ▪1 <= nums.length <= 10^4
  • ▪-10^9 <= nums[i] <= 10^9
  • ▪Time complexity should be O(n) or O(n log n)

Watch Out For Edge Cases

  • ▪Consecutive numbers 1–n (no missing)
  • ▪All same number
  • ▪n = 1
Frequently Asked At
MicrosoftAmazonFlipkartTCS