Categorygithub.com/ductnn/coding-practicealgoexpertCoding-Interview-QuestionsArraysBluemove-element-to-end
package
0.0.0-20241225161807-6c2a4c2dbe8f
Repository: https://github.com/ductnn/coding-practice.git
Documentation: pkg.go.dev
# README
Move Element to End
Problem
-
Difficulty: Blue, Category: Arrays
You're given an array of integers and an integer. Write a function that moves all instances of that integer in the array to the end of the array and returns the array.
The function should perform this in place (i.e., it should mutate the input array) and doesn't need to maintain the order of the other integers.
Sample Input
array = [2, 1, 2, 2, 2, 3, 4, 2] toMove = 2
Sample Output
[1, 3, 4, 2, 2, 2, 2, 2] // the numbers 1, 3, and 4 could be ordered differently