Intern — Middle
Determining dominant numbers and finding the first opposite in the string
livecode
Task condition
Given a string containing integers separated by spaces. Implement a function that counts which type of numbers is more—even or odd. If there are more even numbers, the function should return the first odd number found; if odd, the first even number. If there are no numbers of the opposite type in the string, return None.
Example 1:
Input: 2 4 6 7 8
Output: 7
Example 2:
Input: 1 3 5 4 7
Output: 4
Example 3:
Input: 2 4 6 8
Output: None