← Amazon Interview Insights

Amazon·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
May 2026

Summary

Amazon SWE online assessment with a simulation-style coding problem about CPU credit tracking. Pretty straightforward premise but the math tripped me up at first.

Questions Asked (1)

Q1

Given a list of hourly CPU usage rates and a maximum available CPU usage, write a program to calculate the total CPU credits gained or consumed over the time period.

Algorithms & Data Structures
Author's notes

Took me a minute to realize the credit math is just summing (max_usage minus actual_usage) for each hour, positive means you banked credits, negative means you spent them.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the rules for credit accrual and consumption, then iterate through the hourly usage list, comparing each value to the maximum available CPU. Accumulate credits when usage is below the max and deduct when above, handling edge cases like exactly at max and negative totals.

Pro tip: Mention that this is similar to Amazon EC2 CPU credit model and discuss how you would handle large input streams efficiently, showing awareness of real-world constraints.

1. Clarify requirements and assumptions

Ask about the credit rate (e.g., 1 credit per CPU-hour below max), whether credits can go negative, and if there's a cap on accrued credits. Confirm input format and expected output.

2. Define the algorithm

For each hourly usage, compute the difference (max - usage). If positive, add to total credits; if negative, subtract. Keep a running total.

3. Handle edge cases

Consider usage exactly equal to max (no change), empty list, all usage above max (total negative), and potential integer overflow for large lists.

4. Implement and test

Write clean code with a loop, then test with sample inputs including edge cases. Discuss time and space complexity (O(n) time, O(1) space).

5. Discuss optimizations and extensions

Mention how to handle streaming data, parallelization for large datasets, or variations like different credit rates per hour.

Key Points to Mention

  • Clarify credit accrual and consumption rules upfront
  • Use a single pass O(n) algorithm with O(1) extra space
  • Handle edge cases: empty list, usage equal to max, negative total credits
  • Consider integer overflow and use appropriate data types
  • Relate to real-world systems like AWS EC2 CPU credits
  • Discuss potential optimizations for large-scale data

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.