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!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow 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 Feb 2026
Contest runs February 1 - 28. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.