โ Back to Arrays
Question 399
Move All Zeros to the End
Move All Zeros to the End
The array{0, 1, 0, 3, 12}is given. Move every0to the end while keeping the relative order of the non-zero elements the same, then print the array on one line separated by single spaces: 1 3 12 0 0 The non-zero values stay in their original order (1,3,12), followed by the zeros. Modify the array in place.
Expected Output:
1 3 12 0 0
Topics:
Arrays
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (sysout, psvm, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.