This question runs in a pre-configured Salesforce environment - no personal connection required.
Create a method that returns a map where the key is an Account name and the value is a list of Contact full names for that account. Only include accounts from a specified industry. Use relationship queries to retrieve contacts associated with each account, and format each contact name as "FirstName LastName".
The method should accept one parameter: the industry to filter accounts. Return a map where account names are keys and lists of formatted contact names are values.
Method Signature
public static Map<String, List<String>> getContactsByAccountIndustry(String industry)
Examples
Example 1:
Input: industry = 'Technology'
Output: {'Tech Corp' => ['John Smith', 'Jane Doe'], 'Digital Solutions' => ['Bob Johnson']}
Explanation: Returns Technology accounts with their contacts, each contact formatted as "FirstName LastName"
Example 2:
Input: industry = 'Healthcare'
Output: {'MedCare Systems' => ['Alice Brown'], 'Health Plus' => ['Charlie Davis', 'Diana Wilson']}
Explanation: Returns Healthcare accounts grouped with their contact full names
Example 3:
Input: industry = 'Manufacturing'
Output: {}
Explanation: No Manufacturing accounts with contacts exist, so an empty map is returned
Example 4:
Input: industry = null
Output: {}
Explanation: When industry is null, return an empty map
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
Contest Alert
Contest runs January 1 - 31. Complete challenges to climb the leaderboard!
Points are calculated for challenges completed during the contest period.