Skip to content
Onsite

Even Elements of an Array

EasyP3Coding

Return the even elements of nums, in their original order. Return an empty array if there are none. Zero and negative even numbers count as even.

Example 1

Input
nums = [1,2,3,4,5,6]
Output
[2,4,6]

Example 2

Input
nums = [1,3,5]
Output
[]

Example 3

Input
nums = []
Output
[]

Constraints

  • 0 <= nums.length <= 10^5
  • -10^9 <= nums[i] <= 10^9

Hints

Run checks the 3 visible tests, Submit all 10.