Math Fundamentals18 sections · 814 units
Open in Course

Problem - Find All Numbers Disappeared in an Array

LeetCode 448

Given an array nums of nn integers where nums[i] is in the range [1,n][1, n], return an array of all the integers in the range [1,n][1, n] that do not appear in nums.

Example: nums = [4,3,2,7,8,2,3,1]. The numbers 55 and 66 are missing. Return [5, 6].

You'll use boolean flags (presence markers) to track which numbers appear. The constraint: do this without extra space (ignore the output array).