Here is the interview question prompt, presented for reference.
Write a method that moves all zeros in an array to its end. You should maintain the order of all other elements. Here's an example:
js
zerosToEnd([1, 0, 2, 0, 4, 0])
// [1, 2, 4, 0, 0, 0]
Here's another one:
js
zerosToEnd([1, 0, 2, 0, 4, 0])
// [1, 2, 4, 0, 0, 0]
Fill in the following function signature:
js
function zerosToEnd(nums) {
return;
};
Can you do this without instantiating a new array?
100000
-2147483648
and 214748364
O(n)
O(1)
You can see the full challenge with visuals at this link.
Challenges • Asked 8 months ago by Anonymous
This is the main discussion thread generated for Zeros To The End.
The coding language choices are only javascript and python. It would be really nice if we could have C++ too.
[deleted]
C++ is coming soon, probably this spring 2021.