Given a list of Contact records, attempt to delete them using Database.delete with the allOrNone parameter set to false. This allows partial success - some records may delete successfully while others may fail. Return a Map with two keys: success containing the count of successfully deleted records, and failed containing the count of failed deletions. Handle null or empty input lists by returning zeros for both counts.
Examples:
Input: contacts = [Contact1, Contact2, Contact3] (all deletable)
Output: {'success': 3, 'failed': 0}
Explanation: All 3 contacts were successfully deleted
Input: contacts = null
Output: {'success': 0, 'failed': 0}
Explanation: Null input returns zero counts for both success and failed
Input: contacts = []
Output: {'success': 0, 'failed': 0}
Explanation: Empty list returns zero counts for both success and failed
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 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.