Back to course home
0% completed
Vote For New Content
JS Solution
matthew.herron77
May 14, 2024
It said to not use any additional memory but I needed nonDup , count and next
class Solution { moveElements(arr) { // TODO: Write your code here let nonDup = 1; let count = 0; for (let next=0; next<arr.length; next++) { if (next === 0) continue; if (arr[next] !== arr[next-1]) { arr[nonDup] = arr[next] nonDup++; count++ } } return count + 1; } }
0
0
Comments
Comments
On this page
Problem Statement
Try it yourself