Skip to content

Instantly share code, notes, and snippets.

View therealbigzeez's full-sized avatar
🌍
Somewhere on earth

Azeez Lukman therealbigzeez

🌍
Somewhere on earth
View GitHub Profile
@therealbigzeez
therealbigzeez / countUniqueValues.js
Created December 4, 2023 18:43
Multiple Pointers - countUniqueValues
function countUniqueValues(arr) {
if (arr.length === 0) {
return 0;
}
let i = 0; // Slow pointer
for (let j = 1; j < arr.length; j++) {
if (arr[i] !== arr[j]) {
i++;
arr[i] = arr[j];