Skip to main content

Checkpoint: filter into a new array

Challenge on lesson: Checkpoint: arrays

CHALLENGE
Difficulty: beginner+25 XP

Implement int[] trimNegatives(int[] arr): return a new array holding only the non-negative elements of arr, in their original order. Two passes make it clean: first count them, then fill.

Back to lesson: Checkpoint: arrays