Created
October 31, 2018 06:51
-
-
Save srph/4f30fab7904dfbb2aa65486f98a047ca to your computer and use it in GitHub Desktop.
Codility: Find the smallest natural number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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