removeZeros
Category: Programming
Author: Stuart Reges
Book Chapter: 7.4
Problem: removeZeros
Write a static method called removeZeros that takes an array of integers as a parameter and that moves any zeros in the array to the end of the array, otherwise preserving the order of the list. For example, if a variable called "list" stores the following values: [7, 2, 3, 0, 4, 6, 0, 0, 13, 0, 78, 0, 0, 19, 14] then the call: removeZeros(list); should rearrange the values in the array so that it stores the following: [7, 2, 3, 4, 6, 13, 78, 19, 14, 0, 0, 0, 0, 0, 0] Notice that the six zeros have been moved to the end of the array and the other values are in the same order as in the original list. You are not allowed to use an auxiliary data structure such as a temporary array or ArrayList to solve this problem and you are not allowed to call any methods of the Arrays class or the Collections class.