Skip to content

Instantly share code, notes, and snippets.

@srph
Created October 31, 2018 06:51
Show Gist options
  • Save srph/4f30fab7904dfbb2aa65486f98a047ca to your computer and use it in GitHub Desktop.
Save srph/4f30fab7904dfbb2aa65486f98a047ca to your computer and use it in GitHub Desktop.
Codility: Find the smallest natural number
function solution(A) {
var natural = Array.from(new Array(10000)).map((_, i) => i + 1)
return natural.sort((a, b) => a - b).find((n) => !A.includes(n))
}
console.log(solution([1,2,5]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment