> For the complete documentation index, see [llms.txt](https://algorithm.prettylog.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://algorithm.prettylog.com/algorithm-problems/algoexpert/medium/missing-numbers.md).

# Missing Numbers

![](/files/iBVNaT7PprRHTrf2pvCW)

* n, n

```jsx
function missingNumbers(nums) {
  const set = new Set(nums);

  const answer = [];
  for (let i = 1; i <= nums.length + 2; i++) {
    if (set.has(i)) continue;
    answer.push(i);
  }
  
  return answer;
}

// Do not edit the line below.
exports.missingNumbers = missingNumbers;
```

* space optimized: n, 1

```jsx
```
