This question runs in a pre-configured Salesforce environment - no personal connection required.
Write a method that queries every Opportunity in the org and returns a Map of Account Id to the largest Amount across all that account Opportunities. The method must consider both open and closed Opportunities. The result is a Map whose key is the parent Account Id and whose value is the maximum Amount for that account. If two Opportunities share the same maximum Amount, either is acceptable. Opportunities with a null AccountId must be excluded.
Examples:
Method signature:
public static Map<Id, Decimal> largestOpportunityPerAccount()
Returns:
A Map keyed by AccountId containing the maximum Amount across
all Opportunities linked to that account.
Sample output shape:
{
'001XX0000004AAA' => 985000,
'001XX0000005BBB' => 1250000,
'001XX0000006CCC' => 200000,
...
}
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
🏆 All Time Leaderboard
Contest runs January 1, 1970 - December 31, 9999. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.