We’re preparing your current view and syncing the latest data.
Filter elements from an array
gfgGiven an array and a condition, remove elements from the array that satisfy the condition, and return the filtered array.
An array of elements, and a condition (typically a predicate function or a value to filter out).
An array containing elements that do not satisfy the condition.
Constraints depend on specific problem requirements but typically involve array size limits and element value ranges.
Example 1
Input
[1, 2, 3, 4, 5]; remove even numbers
Output
[1, 3, 5]
Explanation
All even numbers 2 and 4 are removed from the array.