Skip to content

Instantly share code, notes, and snippets.

@laddered
Created January 23, 2020 08:48
Show Gist options
  • Save laddered/a4ba475a3967f4f7405720ae4ed74f09 to your computer and use it in GitHub Desktop.
Save laddered/a4ba475a3967f4f7405720ae4ed74f09 to your computer and use it in GitHub Desktop.
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