Created
November 17, 2018 07:04
-
-
Save MacTanomsup/25c50bd8d49d39a2a2c0a8de5581718a 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 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; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Hiii