Minimum Donation Tier That Fits Each Venue
Problem
You are given two DataFrames.
`venues` — one row per venue:
| Column | Type |
|----------|------|
| venue_id | int |
| seats | int |
`venue_id` is unique. `seats` is how many attendees the venue can hold.
`tiers` — one row per donation tier:
| Column | Type |
|-----------|------|
| donation | int |
| attendees | int |
`donation` is unique. Each row means: at this donation level, `attendees` people are expected to attend.
For each venue, find the smallest `donation` tier whose expected `attendees` does **not exceed** the venue's `seats` (so the crowd fits). Return `venue_id` and that minimum donation in a column named `min_donation`. If no tier fits, return `-1` for that venue. Return the result in any order.
Input data
Example rows — the live problem includes the full dataset.
| venue_id | seats |
|---|---|
| 1 | 50 |
| 2 | 200 |
| 3 | 10 |
| donation | attendees |
|---|---|
| 100 | 30 |
| 200 | 120 |
| 300 | 180 |
Expected output
Your answer should return 3 rows with the columns venue_id, min_donation.
Starter code (Pandas (Python))
import pandas as pd
def minimum_donation_tier(venues: pd.DataFrame, tiers: pd.DataFrame) -> pd.DataFrame:
# Your code here
return venuesSolve this Pandas question free
Write Pandas (Python) and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock