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!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

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 Mar/April 2026

Contest runs March 3 - April 30. Complete challenges to climb the leaderboard!

Points are calculated for challenges completed during the contest period.