Unclear/incorrect task description, Java: Remove Even Numbers

Niall asked 1 week ago


I don’t like the title or this part of the description:
“Given an ArrayList of Integers nums, remove all even numbers.

To me, this appears to describe carrying out a mutation of the original list, rather than what I believe to be the intended behaviour: creating a new filtered copy of the list.

Also, I played around a bit, and it will happily accept me either returning a new list copy of the list with the evens removed or performing an inline remove and returning a reference to the original list.

Personally, I’d prefer an either/or — an inline delete (based on mutation, no return type) or a non-destructive copy-and-delete, specifying (and testing) that the original list must remain unchanged.

Your Answer