ORIGINAL CODING QUESTION
Maximum mentor assignment matching
Assign left-side learners to compatible right-side mentors. Each learner and mentor may appear in at most one assignment. Return the maximum assignment count.
Original exercise · hard. Editorial role relevance does not imply a company has asked this question.
Input and output
leftCount rightCount m, then m compatibility pairs (learner,mentor), each zero-based on its side.
Constraints
1 ≤ leftCount,rightCount ≤ 30; 0 ≤ m ≤ 100; no repeated pairs.
Example 1
Input
2 2 3 0 0 0 1 1 0
Output
2
Assign learner 0 to mentor 1 and learner 1 to mentor 0.
Example 2
Input
2 1 2 0 0 1 0
Output
1
Only one mentor can be used.
Explain your approach
Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?
Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.
Hint 1
A greedy assignment may block a better overall matching.
Hint 2
An augmenting path can reassign existing pairs.
Hint 3
For each learner search with a fresh visited-mentor set.
Practice this question
Save your work privately, explain decisions and return to your revision queue.
Open practice workspaceBrowse the question library →