Skip to content

Instantly share code, notes, and snippets.

@alireza-mpr
Last active November 13, 2020 13:51
Show Gist options
  • Save alireza-mpr/429ef9894a068c325921f62ab40e57e4 to your computer and use it in GitHub Desktop.
Save alireza-mpr/429ef9894a068c325921f62ab40e57e4 to your computer and use it in GitHub Desktop.
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