InterviewDB
Question
Candidate Connection - Match Job Candidates to Positions by Skills
phone
Question Details
Problem
You have a list of candidates {id, skills: Set[str]} and a list of positions {id, required_skills: Set[str], preferred_skills: Set[str]}. Find the best candidate for each position. Score:
- +2 per required skill matched.
- +1 per preferred skill matched.
- A candidate is eligible only if they match ALL required skills.
Return the top match per position (highest score; break ties by candidate ID ascending).
Return null if no eligible candidate exists.
python
def match_candidates(
candidates: List[dict],
positions: List[dict]
) -> dict: # {position_id: candidate_id | None}
...
Example:
candidates = [{"id":"c1","skills":{"python","sql","ml"}},
{"id":"c2","skills":{"python","sql"}}]
positions = [{"id":"p1","required_skills":{"python","sql"},
"preferred_skills":{"ml"}}]
match_candidates -> {"p1": "c1"} # c1 scores 2+2+1=5, c2 scores 2+2=4
Follow-ups
- How would you turn this into a bipartite maximum matching problem?
- Extend to return the top 3 candidates per position.
- How do you handle partial skill matches (e.g., "Python 3" matches "Python")?
- If there are 100K candidates and 10K positions, how do you avoid O(n*m) computation?
Full Details
Problem
You have a list of candidates {id, skills: Set[str]} and a list of positions {id, required_skills: Set[str], preferred_skills: Set[str]}. Find the best candidate for each position. Score:
- +2 per required skill matched.
- +1 per preferred skill matched.
- A candidate is eligible only if they match ALL required skills.
Return the top match per position (highest score; break ties by candidate ID ascending).
Return null if no eligible candidate exists.
python
def match_candidates(
candidates: List[dict],
positions: List[dict]
) -> dict: # {position_id: candidate_id | None}
...
Example:
candidates = [{"id":"c1","skills":{"python","sql","ml"}},
{"id":"c2","skills":{"python","sql"}}]
positions = [{"id":"p1","required_skills":{"python","sql"},
"preferred_skills":{"ml"}}]
match_candidates -> {"p1": "c1"} # c1 scores 2+2+1=5, c2 scores 2+2=4
Follow-ups
- How would you turn this into a bipartite maximum matching problem?
- Extend to return the top 3 candidates per position.
- How do you handle partial skill matches (e.g., "Python 3" matches "Python")?
- If there are 100K candidates and 10K positions, how do you avoid O(n*m) computation?
Free preview. Unlock all questions →
Topics
Coding
Onsite
Phone
More from LinkedIn
Reddit
UPDATE: HR specialist viewed my linkedin profile after final interview?
Reddit
[Insights, advice, and my experience] Got offers from Zapier, Samsara, and PayPal
Reddit
Correlation to Hiring Manager viewing profile, and made a hire?
Reddit
Rejected from job and then got a request to chat over LinkedIn?
Reddit
What's the vibe?