This question runs in a pre-configured Salesforce environment - no personal connection required.

Given a list of Account records with External_Id__c values, perform an upsert operation using the External_Id__c field as the external ID. Return a map with two keys: 'inserted' containing the count of newly inserted records, and 'updated' containing the count of updated records. Handle null or empty lists by returning a map with both counts set to 0.

Examples:

Input: accounts = [Account with External_Id__c='EXT-001', Account with External_Id__c='EXT-002'] Output: {'inserted' => 2, 'updated' => 0} Explanation: Two new accounts inserted, zero updated Input: accounts = [Account with existing External_Id__c='EXT-001'] Output: {'inserted' => 0, 'updated' => 1} Explanation: One existing account updated, zero inserted Input: accounts = null Output: {'inserted' => 0, 'updated' => 0} Explanation: Null input returns map with zero counts
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.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In