Last active
November 13, 2020 13:51
-
-
Save alireza-mpr/429ef9894a068c325921f62ab40e57e4 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) { | |
// write your code in JavaScript (Node.js 8.9.4) | |
const unique = [...new Set(A)].sort((x,y)=>x-y); | |
if(unique.length!=A.length) return 0; | |
for(let cntr=0; cntr<unique.length; cntr++) | |
if(cntr+1 != unique[cntr]) | |
return 0; | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment