Skip to content

Instantly share code, notes, and snippets.

@MacTanomsup
Created November 17, 2018 07:04
Show Gist options
  • Select an option

  • Save MacTanomsup/25c50bd8d49d39a2a2c0a8de5581718a to your computer and use it in GitHub Desktop.

Select an option

Save MacTanomsup/25c50bd8d49d39a2a2c0a8de5581718a to your computer and use it in GitHub Desktop.
function countUniqueValues(arr){
if(arr.length === 0) return 0;
var i = 0;
for(var j = 1; j < arr.length; j++){
if(arr[i] !== arr[j]){
i++;
arr[i] = arr[j]
}
}
return i + 1;
}
@mabjanshaik653
Copy link

Hey Hiii

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment