You are given a set of support tickets and a set of analysts. Each ticket belongs to a domain, has a required complexity, and has a priority. Each analyst supports one or more domains and has a maximum complexity level they can handle.
Tickets must be assigned to analysts subject to the following rules:
P1, then P2, then P3.P1 tickets first. Subject to that, maximize P2, and finally maximize P3.[p1_assigned, p2_assigned, p3_assigned].is an array where each ticket is:
tickets[ticket_id, domain, complexity, priority]
where:
ticket_id is a unique string.domain is a string.complexity is an integer from 1 to 5.priority is one of "P1", "P2", "P3".analysts is an array where each analyst is:
[analyst_id, supported_domains, skill]
where:
analyst_id is a unique string.supported_domains is a non-empty list of domain strings.skill is an integer from 1 to 5.0 <= len(tickets) <= 400 <= len(analysts) <= 40complexity and skill are integers in [1, 5].priority is exactly one of "P1", "P2", "P3".ticket_id, analyst_id, and every domain name are single whitespace-free tokens.tickets = [
["T1", "network", 2, "P1"],
["T2", "security", 3, "P2"],
["T3", "network", 1, "P3"]
]
analysts = [
["A1", ["network", "security"], 3],
["A2", ["network"], 2]
]
Output:
[1, 1, 0]
Explanation:
For P1, T1 can be assigned to either A1 or A2. Suppose it is assigned to A1.
For P2, T2 requires security, so only A1 can handle it, but A1 is already assigned. An augmenting path can reassign T1 from A1 to A2, freeing A1 for T2.
Thus:
Both P1 and P2 are assigned.
T3 cannot be assigned because both analysts are occupied and no augmenting path can increase the total without reducing the higher-priority assignment.
Result: [1, 1, 0].
tickets = [
["T1", "network", 1, "P1"],
["T2", "security", 1, "P1"],
["T3", "network", 1, "P3"]
]
analysts = [
["A1", ["network", "security"], 5],
["A2", ["network"], 5]
]
Output:
[2, 0, 2]
Explanation:
Both P1 tickets can be matched:
Therefore the maximum P1 count is 2.
No analyst remains for T3, so the final result is [2, 0, 0] if assignments are strictly exclusive across all priority tiers.
If the intended specification permits lower-priority rematching after fixing the maximum P1 count, then the expected result is [2, 0, 0]; the implementation must follow the strict-priority rule described above.
A simple greedy strategy such as:
for each ticket:
assign the first free compatible analyst
is not sufficient.
You must support reassignment using augmenting paths so that the maximum possible number of tickets is assigned within each priority tier.
For example, assigning a flexible P1 ticket to A1 may prevent a security P1 ticket from being assigned. The algorithm should be able to move the first ticket to another compatible analyst.
Implement a function that receives tickets and analysts and returns:
[p1_assigned, p2_assigned, p3_assigned]
The exact function signature depends on the language starter code.
LSEG - London Stock Exchange • Pending
LSEG - London Stock Exchange • Pending
LSEG - London Stock Exchange • Pending
LSEG - London Stock Exchange • Pending