Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Scheduling Tool With Conflicts

HardPython00:00
Practice interviewer
In session
5 left
00:00

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.

You need to log in / sign up to run or submit.

Problem

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).

Formal Specification

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.

Constraints

  • 1 <= total number of activities <= 2 * 10^5
  • 0 <= start < end <= 10^9
  • 0 <= priority <= 10^6
  • Activity IDs are globally unique
  • Activities for different employees do not conflict

Function Signature

def resolve_schedules(employees):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output