Amazon SDE Intern OA Problems 2026

amazon logo
amazon
· SDE Intern
February 20, 2026 · 6 reads

Summary

I recently completed an Online Assessment for an Amazon SDE Intern position, which featured two distinct algorithmic problems. I provided my attempted solutions and reflected on the challenges faced.

Full Experience

Hey everyone, I recently appeared for an Amazon SDE Intern OA and wanted to discuss two problems I faced. I solved them partially but would really like to see cleaner or more optimal approaches from the community.Also i need some guidance how to improve in such OAs , i have mentioned mistakes i made here .

Problem 1 — EC2 Instance Allocation Cost

We are given an array representing the number of instances available for each machine type. Customers arrive one by one (M customers total).

For each customer:

  • Allocate an instance from the machine type having the maximum available instances.
  • The cost incurred by that customer = (maximum instances before allocation) + (minimum non-zero instances currently present).
  • After allocation, reduce that machine’s instance count by 1.
  • Continue until all customers are processed or instances run out.

We need to return the total cost incurred by all customers.

Example:
Instances = [1, 3, 2, 4]
Customer 1 → max=4, min=1 → cost=5 → array becomes [1,3,2,3]
…and so on.

Curious about:

  • Best data structure choice?
  • Any mathematical optimization beyond simulation?

I actually got 8/15 test cases for this problem using greedy sorting approach but i think treemap would have been better here .

Problem 2 — Frequent Item Pair from Orders

Given a list of order strings like:

["B03 B06 B08", "B06 B08", "B12 B06"]

Each string contains product IDs bought together.

Task:

Generate all unique unordered pairs of products bought together.

  • If an order has exactly 2 items → that pair itself counts.
  • If more than 2 items → generate all combinations of size 2.

Count frequency of each pair.

Return the pair with highest frequency.

If multiple pairs have same frequency → return lexicographically smallest pair.

Example:
"B03 B06 B08" → (B03,B06), (B03,B08), (B06,B08)

Interested in:

  • Cleaner implementation ideas
  • Handling large inputs efficiently
  • Any similar known problems/patterns

This problem is where i made silly mistakes tried brute force the constraints was 50 , but because of intense pressure i made a silly string length calculation mistake instea of 7 string length i used 2 for a pair length and could not figure out where i went wrong so 0/15 test cases passed :(

Interview Questions (2)

1.

EC2 Instance Allocation Cost

Data Structures & Algorithms

We are given an array representing the number of instances available for each machine type. Customers arrive one by one (M customers total).

For each customer:

  • Allocate an instance from the machine type having the maximum available instances.
  • The cost incurred by that customer = (maximum instances before allocation) + (minimum non-zero instances currently present).
  • After allocation, reduce that machine’s instance count by 1.
  • Continue until all customers are processed or instances run out.

We need to return the total cost incurred by all customers.

Example:
Instances = [1, 3, 2, 4]
Customer 1 → max=4, min=1 → cost=5 → array becomes [1,3,2,3]
…and so on.

2.

Frequent Item Pair from Orders

Data Structures & Algorithms

Given a list of order strings like:

["B03 B06 B08", "B06 B08", "B12 B06"]

Each string contains product IDs bought together.

Task:

Generate all unique unordered pairs of products bought together.

  • If an order has exactly 2 items → that pair itself counts.
  • If more than 2 items → generate all combinations of size 2.

Count frequency of each pair.

Return the pair with highest frequency.

If multiple pairs have same frequency → return lexicographically smallest pair.

Example:
"B03 B06 B08" → (B03,B06), (B03,B08), (B06,B08)

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

Be the first to share your thoughts and start the discussion!