Skip to content

Commit

Permalink
*
Browse files Browse the repository at this point in the history
  • Loading branch information
imteekay committed Jan 1, 2024
1 parent 7019d4f commit 6d994d3
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
// Space: O(1)

function moveElementToEnd(array, toMove) {
let count = 0;
let pointer = 0;

for (let index = 0; index < array.length; index++) {
if (array[index] === toMove) count++;
else {
if (array[index] !== toMove) {
array[pointer] = array[index];
pointer++;
}
Expand Down

0 comments on commit 6d994d3

Please sign in to comment.