Mark As Completed Discussion

Good morning! Here's our prompt for today.

We're given an array of continuous numbers that should increment sequentially by 1, which just means that we expect a sequence like:

[1, 2, 3, 4, 5, 6, 7]

However, we notice that there are some missing numbers in the sequence.

[1, 2, 4, 5, 7]

Description

Can you write a method missingNumbers that takes an array of continuous numbers and returns the missing integers?

JAVASCRIPT
1missingNumbers([1, 2, 4, 5, 7]);
2// [3, 6]

Constraints

  • Length of the array <= 100000
  • The array will always contain non negative integers (including 0)
  • Expected time complexity : O(n)
  • Expected space complexity : O(1)

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

Tired of reading? Watch this video explanation!

To change the speed of the video or see it in full screen, click the icons to the right of the progress bar.

We'll now take you through what you need to know.

How do I use this guide?