public class DepartmentEmployees {
public static void main() {
// Create a map with department names as keys and lists of employee names as values
Map<String, List<String>> departmentEmployeesMap = new Map<String, List<String>>();
// Add sample data to the map
departmentEmployeesMap.put('Sales', new List<String>{'Alice', 'Bob', 'Charlie'});
departmentEmployeesMap.put('Engineering', new List<String>{'Dave', 'Eve', 'Frank'});
departmentEmployeesMap.put('Marketing', new List<String>{'Grace', 'Heidi', 'Ivan'});
// Print the map
for (String department : departmentEmployeesMap.keySet()) {
System.debug('Department: ' + department);
System.debug('Employees: ' + departmentEmployeesMap.get(department));
}
}
}
cHVibGljIGNsYXNzIERlcGFydG1lbnRFbXBsb3llZXMgewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKCkgewogICAgICAgIC8vIENyZWF0ZSBhIG1hcCB3aXRoIGRlcGFydG1lbnQgbmFtZXMgYXMga2V5cyBhbmQgbGlzdHMgb2YgZW1wbG95ZWUgbmFtZXMgYXMgdmFsdWVzCiAgICAgICAgTWFwPFN0cmluZywgTGlzdDxTdHJpbmc+PiBkZXBhcnRtZW50RW1wbG95ZWVzTWFwID0gbmV3IE1hcDxTdHJpbmcsIExpc3Q8U3RyaW5nPj4oKTsKCiAgICAgICAgLy8gQWRkIHNhbXBsZSBkYXRhIHRvIHRoZSBtYXAKICAgICAgICBkZXBhcnRtZW50RW1wbG95ZWVzTWFwLnB1dCgnU2FsZXMnLCBuZXcgTGlzdDxTdHJpbmc+eydBbGljZScsICdCb2InLCAnQ2hhcmxpZSd9KTsKICAgICAgICBkZXBhcnRtZW50RW1wbG95ZWVzTWFwLnB1dCgnRW5naW5lZXJpbmcnLCBuZXcgTGlzdDxTdHJpbmc+eydEYXZlJywgJ0V2ZScsICdGcmFuayd9KTsKICAgICAgICBkZXBhcnRtZW50RW1wbG95ZWVzTWFwLnB1dCgnTWFya2V0aW5nJywgbmV3IExpc3Q8U3RyaW5nPnsnR3JhY2UnLCAnSGVpZGknLCAnSXZhbid9KTsKCiAgICAgICAgLy8gUHJpbnQ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