ORIGINAL CODING QUESTION
Most tasks matched to learners
Each learner has a skill level and each practice task has a difficulty. A learner may take a task only when their skill is at least the task difficulty, each learner takes at most one task, and each task goes to at most one learner. Return the largest number of tasks that can be assigned.
Original exercise · medium. Editorial role relevance does not imply a company has asked this question.
Input and output
n m, then n skill levels, then m task difficulties.
Constraints
1 ≤ n, m ≤ 100; 0 ≤ skill, difficulty ≤ 1000.
Example 1
Input
3 4 5 2 8 1 6 9 3
Output
3
Skills 2, 5, 8 take tasks 1, 3, 6; task 9 stays open.
Example 2
Input
2 2 1 1 2 2
Output
0
No learner is skilled enough for any task.
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
Easy tasks are the cheapest to satisfy.
Hint 2
Sort both lists ascending.
Hint 3
Walk learners from weakest to strongest; give each the easiest unassigned task they can handle.
Practice this question
Save your work privately, explain decisions and return to your revision queue.
Open practice workspaceBrowse the question library →