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!

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 November 2026 (Nov 16–30)Sponsored by FLXBL

Contest runs November 16 - 30. Complete challenges to climb the leaderboard!

Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes

Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In