Your question is Scheduling Tool With Conflicts. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
In a Palantir Foundry operational workflow, employees may have overlapping proposed activities. Implement a scheduling tool that selects a conflict-free subset for each employee while maximizing total priority.
Each activity belongs to exactly one employee. Activities are compatible when the earlier activity's end time is less than or equal to the later activity's start time. If multiple schedules have the same total priority, prefer the schedule with fewer activities, then the lexicographically smallest activity-ID sequence when activities are ordered by (end, start, id).
Implement resolve_schedules(employees), where employees is a dictionary mapping employee names to lists of activity dictionaries. Every activity contains a unique string id, an integer start, an integer end, and a non-negative integer priority. Return a dictionary with accepted and rejected lists containing every activity ID exactly once. Return accepted IDs in lexicographic order, and rejected IDs in lexicographic order.
def resolve_schedules(employees):