This question runs in a pre-configured Salesforce environment - no personal connection required.
Return the top N accounts by annual revenue for a specified country. The accounts should be sorted by revenue in descending order (highest revenue first). If the country is null or if topN is less than or equal to 0, return an empty list. If there are fewer accounts in the country than topN, return all accounts from that country.
Examples:
Input: country = "USA", topN = 3
Output: List of top 3 USA accounts sorted by AnnualRevenue descending
Explanation: Returns the 3 highest revenue accounts from USA
Input: country = "Germany", topN = 1
Output: List with the single highest revenue German account
Explanation: Returns only the top account from Germany
Input: country = null, topN = 5
Output: Empty list
Explanation: Null country returns empty list
Welcome to Lightning Challenge!
Create an Account
Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.
Create accountHow 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