Retired

Remove Zeros (retired)

6,529 of 6,542AustinBrunkhorst

Description:

Write a function that takes an array of values and moves all elements that are zero to the end of the array, otherwise preserving the order of the array. The zero elements must also maintain the order in which they occurred.

For example, the following array

[7, 2, 3, 0, 4, 6, 0, 0, 13, 0, 78, 0, 0, 19, 14]

is transformed into

[7, 2, 3, 4, 6, 13, 78, 19, 14, 0, 0, 0, 0, 0, 0]

Zero elements are defined by either 0 or "0". Some tests may include elements that are not number literals.

You are NOT allowed to use any temporary arrays or objects. You are also not allowed to use any Array.prototype or Object.prototype methods.

Arrays
Sorting
Algorithms

Stats:

CreatedDec 13, 2013
Warriors Trained15151
Total Skips2341
Total Code Submissions80968
Total Times Completed6542
JavaScript Completions6529
Total Stars353
% of votes with a positive feedback rating84% of 839
Total "Very Satisfied" Votes623
Total "Somewhat Satisfied" Votes164
Total "Not Satisfied" Votes52
Ad
Contributors
  • AustinBrunkhorst Avatar
  • farhanaditya Avatar
Ad