Remove Trailing Zeros

Given an int array nums, return it such that all zeros are removed from the end of the array.

removeTrailing([1, 2, 3, 4, 5, 0, 0, 0]) => [1, 2, 3, 4, 5]
removeTrailing([1, 2, 0, 3, 4, 0, 0]) => [1, 2, 0, 3, 4]
removeTrailing([1, 2, 3, 4]) => [1, 2, 3, 4]
removeTrailing([0, 0]) => []
removeTrailing([]) => []

Login / Register

To try your hand at solving this problem you'll need an account on CompSci.Rocks. Please either login or register to continue.

Once you've logged in you'll be able to enter code directly into this page to solve the problem.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *