Given a list of integers, partition them into two groups: even numbers and odd numbers. Return a Map with exactly two keys: 'even' containing the even numbers and 'odd' containing the odd numbers, each preserving the original order.
Return a map with empty lists for both keys if the input is null or empty.
Examples:
Input: numbers = [1, 2, 3, 4, 5]
Output: {even=[2, 4], odd=[1, 3, 5]}
Explanation: Evens are 2 and 4; odds are 1, 3, and 5
Input: numbers = [2, 4, 6]
Output: {even=[2, 4, 6], odd=[]}
Explanation: All even numbers
Input: numbers = [1, 3, 5]
Output: {even=[], odd=[1, 3, 5]}
Explanation: All odd numbers
Input: numbers = []
Output: {even=[], odd=[]}
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 May 2026
Contest runs May 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.