Rank In-Network Therapists for a Patient Search
Last updated: November 29, 2026
Quick Overview
Given a patient's state, insurance plan, clinical needs and modality preferences, filter a list of therapists to those who are licensed in that state, in network for the plan, cover every need and have an opening within 14 days, then return the top k by a score that rewards preference matches and shorter waits.
Headway
November 29, 20260
0
0 solved
Given a patient's state, insurance plan, clinical needs and modality preferences, filter a list of therapists to those who are licensed in that state, in network for the plan, cover every need and have an opening within 14 days, then return the top k by a score that rewards preference matches and shorter waits.
Matching patients to in-network therapists is the core of Headway's directory, and the hard filters (license state, plan network) are not negotiable while preferences are soft. The interviewer wants clean separation of eligibility filters from scoring, a bounded heap for top k, and deterministic tie-breaking.
What the Interviewer Expects
- Apply hard constraints (license, network, needs, horizon) before scoring
- Define a transparent score and defend its weights
- Use a size k heap so cost is O(n log k), not a full sort
- Break ties deterministically so results do not shuffle between page loads
- Discuss fairness of exposure across therapists
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you avoid always showing the same few therapists and starving new providers of bookings?
- If network status for a plan is uncertain, should that therapist be filtered or shown with a warning?
- How would you evaluate a new ranking function offline before an experiment?
- How does this change when the candidate set is 50,000 therapists and you need results in 100 ms?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Hard filters: therapist licensed in the patient's state, the patient's plan in the therapist's network, every patient need covered by specialties, and a next opening between today and the horizon. Sof...
High-Level Design
Single pass over therapists. Skip anything failing a hard filter. Keep a min-heap of the best k seen so far; when a new candidate beats the heap's minimum, replace it. To make the smaller id win ties ...