Allocate Leads to Pros Under Weekly Budgets

Last updated: November 29, 2026

Quick Overview

Process service requests in time order and assign each to at most N pros chosen by highest match score, only among pros in the right category whose remaining weekly budget covers the lead price; return assignments and spend per pro.

Thumbtack
Coding & Algorithms
Software Engineer
Thumbtack
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Medium

0

0

0 solved


Process service requests in time order and assign each to at most N pros chosen by highest match score, only among pros in the right category whose remaining weekly budget covers the lead price; return assignments and spend per pro.

Thumbtack pros pay per lead and cap their weekly spend, so matching has to respect budgets in real time. The interviewer checks greedy allocation with stateful constraints, deterministic tie-breaking and awareness that greedy by time is not globally optimal.

What the Interviewer Expects
  • Clarifies that requests arrive online and must be decided immediately
  • Tracks remaining budget per pro and skips pros who cannot afford the price
  • Sorts candidates by score with a deterministic tie-break
  • Stops at N pros per request
  • Discusses why greedy can exhaust a strong pro early and what pacing does about it
Key Topics to Cover
Greedy algorithms
Online allocation
Budget pacing
Sorting
Concurrency
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • A top pro burns their budget by Tuesday. How would you pace their spend across the week?
  • How would you handle refunds for leads later marked invalid?
  • How would you make this safe when many servers allocate concurrently?
  • How would an offline optimal solution differ, and how would you compute it?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Pros: map of id to budget and categories. Requests arrive in time order, each with id, category, price and scores (pro id to match score from ranking). For each request choose up to N pros...

High-Level Design

This is an online problem: a request cannot wait for future requests, so we decide greedily per request. State is one dictionary of remaining budget. Per request, build the eligible candidate list, so...


Submit Your Answer
Markdown supported

Related Questions