Auction Lot Bid Summary
Updated
Problem statement
An online auction sells items in lots. lots has one row per lot, with its title and the price the bidding starts at. bids has one row per bid, with the lot it is for, the bidder's username, the amount, and the time it was placed.
For every lot, return lot_id, title, bid_count, current_price and latest_bidder, sorted by lot_id from smallest to largest.
bid_countis the number of bids on the lot. When one bidder bids several times, every bid counts.current_priceis the highest bid amount on the lot. A lot with no bids keeps itsstarting_price.latest_bidderis the bidder of the lot's most recent bid, the one with the latestbid_time. When several bids share that time, take the one with the largestbid_id. A lot with no bids getsNULL.- Every lot appears exactly once, including lots with no bids, which have a
bid_countof0. - A later bid can be lower than an earlier one, so the latest bidder is not always the bidder with the highest amount.
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
lots
One row per auction lot.
| Column | Type | Nullable | Description |
|---|---|---|---|
| lot_idPK | Integer | No | Unique lot ID. |
| title | Text | No | Lot title. Two lots can share a title. |
| starting_price | Integer | No | Price the bidding starts at. |
bids
One row per bid placed on a lot.
| Column | Type | Nullable | Description |
|---|---|---|---|
| bid_idPK | Integer | No | Unique bid ID. IDs do not follow time order. |
| lot_id | Integer | No | The lot the bid is for. |
| bidder | Text | No | Username of the person who placed the bid. |
| amount | Integer | No | Bid amount. |
| bid_time | Timestamp | No | When the bid was placed, to the second. |
Foreign key: lot_id → lots(lot_id)
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| lot_id | Integer | No | — |
| title | Text | No | — |
| bid_count | Integer | No | — |
| current_price | Integer | No | — |
| latest_bidder | Text | Yes | — |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
lotshas between1and200rows, andbidshas between0and1500rows.lot_idandbid_idare unique integers between1and10^9.- Every
bids.lot_idmatches a row inlots. titlehas between1and60characters, andbidderhas between1and30characters.starting_priceandamountare integers between1and10^6, and every bid'samountis at least its lot'sstarting_price.bid_timeis between2020-01-01 00:00:00and2030-12-31 23:59:59, in whole seconds.
More HackerRank interview questions
- REST API: Country CodesOA · Seen Nov 2026
- Classify Password StrengthOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Longest Equal Binary SubarrayOA · Seen Dec 2025
- Longest Equal Binary Subarray After One FlipOA · Seen Dec 2025
- Longest Prefix-Valid Binary SubarrayOA · Seen May 2025
- Check Permutation Divisible by EightONSITE INTERVIEW · Seen Mar 2026
- Ball Passing at Time KPHONE SCREEN · Seen Dec 2025
Similar questions at other companies
- Bond Holders Above the Cash Flow ThresholdBirla Pivot · OA
- Prepare Taxi Driver Classification DataBoston Consulting Group · OABoston Consulting Group interview questions
- Find the Dominant SellerSquadStack.ai · OA
- Track the Book and Mark Final PnLMillennium · OAMillennium interview questions
- Market Share Ticker with ImbalanceWolverine Trading · OAWolverine Trading interview questions
- Overloaded Game Account InventoriesWells Fargo · OAWells Fargo interview questions
- Transaction Totals and Ranked Failure ReasonsIntuit · OAIntuit interview questions
- Employees Joined per MonthOdoo · OAOdoo interview questions
- Bond Haircut by Ratings and MaturityJane Street · OAJane Street interview questions
- Customer Order FeesAdobe · OAAdobe interview questions