Given a list of integers, partition them into two separate lists: one containing all even numbers and one containing all odd numbers. Return a Map with two keys: "even" and "odd", where each key maps to a List of Integers. Maintain the original order of elements. Return null for null input and empty lists for empty input.
Examples:
Input: numbers = [1, 2, 3, 4, 5, 6]
Output: {"even": [2, 4, 6], "odd": [1, 3, 5]}
Explanation: Even numbers (2, 4, 6) and odd numbers (1, 3, 5) are separated
Input: numbers = [2, 4, 6]
Output: {"even": [2, 4, 6], "odd": []}
Explanation: All numbers are even, odd list is empty
Input: numbers = []
Output: {"even": [], "odd": []}
Explanation: Empty input returns map with empty lists
Input: numbers = null
Output: null
Explanation: Null input returns null
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.