The Resume Sifter
A medium Python interview practice problem on DataDriven. Write the Python and run it against test cases, with instant feedback.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L3
- Asked in
- Meta
Problem
Given a list of URLs in the format 'https://resumes.io/firstname_lastname_id' (or 'firstname_id' for single-name variants) and a set existing_ids of known ID strings, return a list of [name_prefix, id] pairs for URLs whose id is NOT in existing_ids, preserving input order. The name_prefix is everything before the LAST underscore; the id is what follows it. Each result pair must be a list of two strings, e.g. ['john_doe', '123'].
Pull what's useful. Skip what you know.
Example
Input:
urls = ["https://resumes.io/john_doe_123","https://resumes.io/jane_smith_456","https://resumes.io/bob_789"], existing_ids = ["456"]
Output:
[["john_doe","123"],["bob","789"]]
Worked solution and explanation
Why this problem exists in real interviews
This tests URL parsing, string extraction, and set-based filtering, a practical combination in ETL workflows. Interviewers check whether candidates can extract structured data from URLs and filter against a known set.
Break down the requirements
Step 1: Parse the URL to extract the path segment
Split on / to get the last path segment containing firstname_lastname_id.
Step 2: Split the segment into name_prefix and ID
The id is the token after the LAST underscore. Use segment.rsplit('_', 1) so a name containing underscores (e.g. john_doe) stays intact as the name_prefix while the trailing token becomes the id.
Step 3: Filter out known IDs
Check each extracted ID against the provided set of known IDs. Keep only new candidates, appending each as a [name_prefix, id] list and preserving input order.
The solution
def filter_new_resumes(urls, existing_ids):
existing = set(existing_ids)
result = []
for url in urls:
segment = url.rstrip('/').split('/')[-1]
name_prefix, candidate_id = segment.rsplit('_', 1)
if candidate_id not in existing:
result.append([name_prefix, candidate_id])
return resultCommon follow-up questions
- What if names could have multiple underscores (e.g., `firstname_middle_lastname_id`)? (Tests using `rsplit('_', 1)` to split from the right for the ID.)
- What if URLs had query parameters? (Tests using `urllib.parse.urlparse` for robust URL parsing.)
- How would you also deduplicate across the incoming batch? (Tests adding extracted IDs to a running seen set.)
- What if the `known_ids` set had millions of entries? (Tests that sets handle this efficiently in Python with O(1) lookups.)