This question runs in a pre-configured Salesforce environment - no personal connection required.
Given a map where each key is a first name and each value is a last name, create Contact records for each entry and insert them into the database. Return a list of the newly created Contact Ids. Return an empty list for null or empty input. The method should perform a single bulk insert operation, not individual inserts inside a loop.
Examples:
Input: nameMap = {'John' => 'Smith', 'Jane' => 'Doe'}
Output: List of 2 Contact Ids
Explanation: Two Contact records are created and inserted, returning their new Ids
Input: nameMap = {'Alice' => 'Wonder'}
Output: List of 1 Contact Id
Explanation: One Contact record is created and inserted, returning its new Id
Input: nameMap = {}
Output: []
Explanation: Empty map returns an empty list
Input: nameMap = null
Output: []
Explanation: Null input returns an empty list
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • This challenge runs without connecting your own org
- • 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.