Amazon software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.
No verified questions yet for Amazon.
EC2:t3.micro:instance-second or S3:STANDARD:GB-hour. Each rate has an inclusive effective timestamp and an integer price in micro-USD per unit. One USD equals 1,000,000 micro-USD. Rates may be inserted out of chronological order. Repeating an identical rate is a no-op; changing the price at an existing effective timestamp raises ValueError.ValueError without storing the event. Otherwise, freeze the calculated charge at acceptance time; subsequently inserted rates never reprice stored events.false, even if the rate schedule has since changed. Reusing its ID with any different payload raises ValueError. A newly accepted event returns true.(meter, region), summing quantities and their frozen charges. Sort invoice lines lexicographically by meter, then region. Each line contains meter, region, quantity, and subtotal_micro_usd.{"account_id": string, "lines": list, "total_micro_usd": integer, "total_cents": integer}. Sum exact charges before rounding: total_cents = (total_micro_usd + 5000) // 10000, which rounds nonnegative amounts to the nearest cent with ties upward. An empty interval has no lines and zero totals. Invoice calls do not modify state; start >= end raises ValueError.Class APIAWSUsageBilling(account_id: str) — construct an empty ledger for one account.set_rate(meter: str, region: str, effective_at: int, unit_price_micro_usd: int) -> None — register a rate version using the conflict rules above.record_usage(event_id: str, meter: str, region: str, timestamp: int, quantity: int) -> bool — accept a new event or handle its retry atomically.invoice(start: int, end: int) -> dict[str, object] — return the invoice structure specified above.billing = AWSUsageBilling("acct-1")
billing.set_rate("EC2:t3.micro:instance-second", "us-east-1", 0, 7500)
billing.set_rate("S3:STANDARD:GB-hour", "us-east-1", 0, 2000)
billing.record_usage("e1", "EC2:t3.micro:instance-second", "us-east-1", 100, 2)
billing.record_usage("e1", "EC2:t3.micro:instance-second", "us-east-1", 100, 2)
billing.record_usage("e2", "S3:STANDARD:GB-hour", "us-east-1", 110, 5)
billing.invoice(100, 111)true, false, and true. The invoice is:{
"account_id": "acct-1",
"lines": [
{"meter": "EC2:t3.micro:instance-second", "region": "us-east-1", "quantity": 2, "subtotal_micro_usd": 15000},
{"meter": "S3:STANDARD:GB-hour", "region": "us-east-1", "quantity": 5, "subtotal_micro_usd": 10000}
],
"total_micro_usd": 25000,
"total_cents": 3
}2 × 7500 = 15000 micro-USD and S3 costs 5 × 2000 = 10000. The combined charge is 2.5 cents, rounded once to 3 cents.Constraints(meter, region) pairs, and 1,000 rate versions per pair.[0, 10^12]; quantities are in [1, 10^9]; prices are in [0, 10^9] micro-USD per unit.billing = AWSUsageBilling("acct-2")
billing.set_rate("EC2:t3.micro:instance-second", "us-east-1", 0, 7500)
billing.record_usage("a", "EC2:t3.micro:instance-second", "us-east-1", 120, 2)
billing.set_rate("EC2:t3.micro:instance-second", "us-east-1", 100, 4000)
billing.record_usage("a", "EC2:t3.micro:instance-second", "us-east-1", 120, 2)
billing.record_usage("b", "EC2:t3.micro:instance-second", "us-east-1", 130, 1)
billing.invoice(120, 131)true, false, and true. The invoice is:{
"account_id": "acct-2",
"lines": [
{"meter": "EC2:t3.micro:instance-second", "region": "us-east-1", "quantity": 3, "subtotal_micro_usd": 19000}
],
"total_micro_usd": 19000,
"total_cents": 2
}a retains its frozen charge of 2 × 7500 = 15000. Event b uses the newly registered rate and costs 1 × 4000 = 4000. Their grouped quantity is 3, but multiplying that quantity by either single rate would be incorrect.NotificationSystem class to manage notifications.def __init__(self): return type None, initializes the notification system.def subscribe(self, user_id: str) -> None: return type None, adds user to subscription list.def unsubscribe(self, user_id: str) -> None: return type None, removes user from subscription list.def schedule_notification(self, user_id: str, message: str, send_time: datetime) -> None: return type None, schedules a notification.def send_notifications(self) -> None: return type None, sends out all scheduled notifications.subscribe("user1"); schedule_notification("user1", "Order shipped!", datetime.now())Nonesend_notifications()"Notifications sent to all subscribers."TicketBooking that manages shows and tickets.def __init__(self): return type None, initializes the booking system.def add_show(self, show_name: str, show_time: str, total_seats: int) -> None: return type None, adds a new show.def book_ticket(self, show_name: str, number_of_seats: int) -> str: return type str, books tickets if available.def cancel_booking(self, show_name: str, number_of_seats: int) -> str: return type str, cancels booked tickets.def available_tickets(self, show_name: str) -> int: return type int, returns remaining tickets.add_show("Spider-Man", "2022-10-01 19:00", 100); book_ticket("Spider-Man", 5); available_tickets("Spider-Man")95cancel_booking("Spider-Man", 3); book_ticket("Spider-Man", 2)"Successfully booked 2 tickets."Sign up for free to access walkthroughs, AI-generated questions, and more.
Get Started Free