Created
January 23, 2020 08:48
-
-
Save laddered/a4ba475a3967f4f7405720ae4ed74f09 to your computer and use it in GitHub Desktop.
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) { | |
A.sort((a, b) => a > b ? 1 : -1); | |
if(A[0]!==1){ | |
return 1 | |
} | |
for (let i=0; i<A.length-1; i++){ | |
if((parseInt(A[i], 10)+1)!==A[i+1]){ | |
return A[i]+1 | |
} | |
} | |
return A[A.length-1]+1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment