Problem
Given a list/array of integers nums, print (or return) every odd number in the list, in the same order they appear.
Clarifications / follow-ups
-
Negative integers may appear.
Negative odd numbers (e.g.,
-3
) should be treated as odd and included.
-
Integers may exceed 32-bit range.
Your approach should still work even if values do not fit in a 32-bit signed integer.
Input
-
nums
: a list of integers.
Output
-
Either print each odd number (one per line) or return a list of odd numbers (state your choice).
Constraints
-
Assume
nums
can be large, so the solution should be linear in the length of the list.