Skip to content
Onsite

Odd Elements of Array

EasyP3Coding

Return the odd elements of nums, in their original order. Negative odd numbers count as odd. Return an empty array if there are none.

Example 1

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

Example 2

Input
nums = [2,4,6]
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.