← Amazon Interview Insights

Amazon·Software Engineer·Onsite - Coding / Algorithms·Intermediate

IntermediatePrefer not to say
May 2026

Summary

Amazon SWE coding round that paired a two-sum variant with a line-intersection problem in what they called an AI-enabled coding session. The main question was dressed up as a movie recommendation problem but it's basically just LC 1 with a flight-duration theme.

Questions Asked (1)

Q1

Given a list of movie runtimes in minutes and a total flight duration, find two movies whose runtimes add up exactly to the flight duration and return their indices (or runtimes, confirm with interviewer).

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

It's two-sum wearing a costume.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the problem requirements first, then propose an efficient solution using a hash map to store runtimes and their indices, allowing a single-pass O(n) time and O(n) space algorithm. Walk through the algorithm with an example, discuss trade-offs with brute force, and handle edge cases like no solution or duplicate runtimes.

Pro tip: Demonstrate Amazon Leadership Principles by proactively discussing trade-offs (e.g., time vs. space) and asking clarifying questions about input constraints and expected output format. This shows customer obsession and ownership.

1. Clarify Requirements

Ask the interviewer to confirm the output format (indices or runtimes), whether the list can contain duplicates, and if a solution is guaranteed to exist.

2. Discuss Approaches

Mention the brute force O(n^2) approach and then propose the optimal O(n) hash map solution, explaining why it's better.

3. Explain Algorithm

Describe the single-pass hash map algorithm: iterate through the list, for each runtime check if its complement (flight duration - runtime) exists in the map; if yes, return indices; else store the runtime and index.

4. Walk Through Example

Use a concrete example (e.g., runtimes [90, 120, 150], flight duration 240) to illustrate how the algorithm finds the pair.

5. Analyze Complexity and Edge Cases

State time and space complexity (O(n) each) and discuss edge cases: no solution, multiple solutions, duplicate runtimes, and negative or zero durations.

Key Points to Mention

  • Hash map for O(1) lookups to achieve O(n) time complexity
  • Trade-off between time and space: O(n) space vs. O(n^2) time for brute force
  • Handling duplicate runtimes correctly (e.g., same movie cannot be used twice)
  • Returning indices vs. runtimes and confirming with interviewer
  • Edge cases: no valid pair, multiple valid pairs, empty list, flight duration less than any runtime
  • Amazon Leadership Principles: Customer Obsession (clarify requirements), Ownership (discuss trade-offs), Dive Deep (edge cases)

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