Consecutive Numbers

Published by JJCUBER in

Create a function that determines whether elements in an array can be re-arranged to form a consecutive list of numbers where each number appears exactly once.

Examples

Cons([5, 1, 4, 3, 2]) ➞ true
// Can be re-arranged to form [1, 2, 3, 4, 5]

Cons([5, 1, 4, 3, 2, 8]) ➞ false

Cons([5, 6, 7, 8, 9, 9]) ➞ false
// 9 appears twice

Notes

N/A

Watch a quick demo on how Edabit works.