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

Note

You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In