This question runs in a pre-configured Salesforce environment - no personal connection required.
Write a method that finds the Account with the highest AnnualRevenue for each Account Type. Return a Map where the key is the Type (String) and the value is the Account Name (String) with the highest revenue for that type. Only include types that have at least one account with non-null AnnualRevenue.
Method Signature:
public static Map<String, String> getHighestRevenueByType()
Examples:
Input: No parameters
Output: {'Customer' => 'Nordic Petroleum', 'Prospect' => 'Mumbai Tech Hub'}
Explanation: Nordic Petroleum has the highest revenue among Customer accounts, and Mumbai Tech Hub has the highest revenue among Prospect accounts
Input: No parameters
Output: {'Customer' => 'Alpine Private Bank'}
Explanation: If only Customer accounts have non-null revenue values, only Customer type appears in the result with its highest revenue account name
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 September 2026 (Sep 1–15)Sponsored by FLXBL
Contest runs September 1 - 15. Complete challenges to climb the leaderboard!
1st & 2nd: Salesforce certification exam voucher — see all prizes
Only the 15 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.