W
W
WarriorKodeK2018-02-20 19:44:48
JavaScript
WarriorKodeK, 2018-02-20 19:44:48

How to find missing element?

Hello.
The essence of the task is to find a pass. number.
For example - Prompt algorithm please. const arr = [2, 5, 1, 4, 9, 6, 3, 7]
missingNum(arr) // => 8

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2018-02-20
@WarriorKodeK

You can sort, and during this check the difference of a smaller number over a larger one, if the result is greater than one, a number is missing between them, find it, add +1 to the smaller one or -1 from the larger one

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question