This question runs in a pre-configured Salesforce environment - no personal connection required.
Transfer all Contacts from a source Account to a target Account by updating the AccountId field. Return the number of Contacts that were successfully transferred.
Return 0 if the source Account has no Contacts. Return null if either the sourceAccountId or targetAccountId is null.
Examples:
Input: sourceAccountId = '001XXXXXXXXXX', targetAccountId = '001YYYYYYYYYY'
Output: 5
Explanation: The source Account had 5 Contacts, all were transferred to the target Account
Input: sourceAccountId = '001XXXXXXXXXX', targetAccountId = '001YYYYYYYYYY'
Output: 0
Explanation: The source Account has no Contacts, so 0 Contacts were transferred
Input: sourceAccountId = null, targetAccountId = '001YYYYYYYYYY'
Output: null
Explanation: Source Account ID is null, return null
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.