AO
Back

Car Rental: Fewest Cars for All Reservations, and Which Car Takes Each

CodingOnsiteLast reported August 2026Medium Frequency

Problem Overview

The round: a car-rental scheduling question in four Google reports from May to August 2026: an L5 phone screen, an L4 AI/ML loop's second round, an L3 onsite round, and a first-round virtual interview. Every version gives a list of rental requests, each with a pickup time and a return time; three of the four also give each request an id. Three ask for the fewest cars that can serve them all; three ask which car serves which request, either filled into a Car object's rental_record or as a map from reservation id to car id. One candidate compared it to LeetCode 253, Meeting Rooms II. Two graded parts.

A request is a tuple (request_id, pickup_time, return_time) with pickup_time < return_time. One car can serve any number of requests that do not overlap. A car returned at time 5 can be picked up again at time 5 (the L5 report states this rule).

Part 1 — the fewest cars

def min_cars(requests: list[tuple[str, int, int]]) -> int: ...
  • Return the smallest number of cars that can serve every request. The requests can come in any order.
requests = [("r1", 0, 30), ("r2", 5, 10), ("r3", 15, 20)]
answer: 2   (r1 needs its own car; r2 and r3 can share one)

Part 2 — which car takes each request

class Car:
    def __init__(self, id):
        self.id = id
        self.rental_record = []
# ...
def assign_cars(requests: list[tuple[str, int, int]]) -> list[Car]: ...
  • Serve every request with as few cars as possible and return the cars used. Each car's rental_record holds the requests it serves (the request tuples; the tests also accept just the ids). Two requests on one car must not overlap. Car ids only need to be distinct.
  • One report gave the Car class above; another asked you to design it. One report returned a dict from reservation id to car id instead; that is {rid: car.id for car in cars for rid, _, _ in car.rental_record}.

Discussed, not graded: three follow-ups were reported without rules. A fleet capped at K cars, fewer than Part 1's answer: what do you do with the requests that cannot be served? (The report does not say whether it was coded; a reply said implementing it fully on the spot is very hard.) Cars that need maintenance as they approach a mileage limit, each maintenance taking several days (described in a reply by another candidate, whose interviewer only wanted the reasoning). Login logs sharded across servers and regions, a change of scenario that was discussion only. None of them came with rules, so none are graded here.

Notes: the function names, the tuple input, the request ids in every test, and every example are ours. One L5 report starts from "given N cars" and still asks for as few cars as possible; the graded parts create cars as needed (see the clarifications).

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Trade-off discussion · 5
Trade-off discussion

How do you know how many cars were used in the end?

Probes for: reported, L3 round, after the candidate returned a dict from reservation id to car id

Why did you choose a dict for the answer?

Probes for: reported, L3 round

If there are at most K cars, and they cannot cover every order, how do you handle it?

Probes for: reported, first-round interview; the report gives no goal, and a reply guessed it means accepting as many requests as possible

Cars need maintenance when they approach a mileage limit, and each maintenance takes y days. How do you find the fewest cars under that constraint?

Probes for: reported in a reply by another candidate; you can maintain at the limit or earlier, and the interviewer only wanted the reasoning

User login logs are sharded over different servers and regions. How would you process them?

Probes for: reported, L4 round, a change of scenario; discussion only, no code

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
Sweep line over pickup and return events, returns before pickups at equal times (gives the count; producing the assignment needs extra bookkeeping). Scanning every car for a free one instead of a heapcorrect, but O(n * c)).

What Reports Emphasize

Interviewer hints: In the L4 round the interviewer said the sharded-logs follow-up was hard, and it needed no code. In the reply describing the maintenance follow-up, the interviewer only wanted to hear the candidate's reasoning.

What passers do: Two of the reports come from loops that passed. The L4 candidate solved it with a sweep line. The L5 report says the key is how you sort the requests and reuse cars that are already free.

What candidates did: The L3 candidate used a heap and returned a dict from reservation id to car id. The first-round candidate sorted by pickup time and kept a min-heap of each car's next free time.

Edge cases to test (ours): A return and a pickup at the same time (the L5 rule: same car). Requests given out of order. Many requests over the same hours. No requests.

Practice

Write your own against 7 test cases, or read the worked solution — approach, complexity, and code that runs.

Prepping for Google with friends?

Send them this page. It is free to read, no account needed.

More Google Questions

Free preview

Every question in the Google catalog gets this depth

What you just read — canonical solution, follow-up arc, what passing candidates actually did — exists for all 48 Google questions, refreshed monthly from new candidate reports.

$59/mo — or $50/mo with the 3-month pass · cancel anytime
Google · Coding · Reported 4× across candidate reports
Is this helpful?