#20 Moving Zeros to the End

Companies:
Wildberries
Themes:
AlgorithmsArraysPractice

Write a method that moves all elements equal to zero to the end of the array while preserving the order of the remaining elements:

// [3, 0, 4, 0, 1] -> [3, 4, 1, 0, 0]
public void moveZerosToEnd(int[] arr) {
    ...
}

Question review

Mentor
Answer as you would in a real interview. I’ll ask follow-up questions, then compare your answer with the reference answer and show your accuracy as a %.
Sign in to start the dialogue The mentor keeps the context of the current question and your previous messages.
Sign in