← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Amazon SWE interview with two coding problems back to back. One was a known LeetCode problem and the other was a custom scheduling problem that felt more involved than it looked.

Questions Asked (2)

Q1

Given four integers a, b, c, d, starting from point (a, b) you can repeatedly apply either (x, y) → (x+y, y) or (x, y) → (x, x+y). Can you determine if it's possible to reach the point (c, d)?

Algorithms & Data Structures
Author's notes

Recognized it as the LeetCode reaching points problem pretty fast, which was a relief.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Work backwards from (c, d) to (a, b) by repeatedly subtracting the smaller number from the larger, since the forward operations only increase one coordinate. Use modulo arithmetic to skip many steps at once, similar to the Euclidean algorithm, and handle edge cases like zero or negative numbers.

Pro tip: Mention that this is essentially the reverse of the subtractive Euclidean algorithm, and that using modulo instead of repeated subtraction reduces time complexity from O(max(c,d)) to O(log(max(c,d))). Also, clarify that the operations are only valid for positive integers, so if any coordinate is non-positive, the answer is immediately false.

1. Understand the operations and constraints

Recognize that each operation adds one coordinate to the other, so both coordinates remain positive and strictly increase. Thus, if (a, b) is not component-wise ≤ (c, d), it's impossible.

2. Reverse the process

From (c, d), the last operation must have been either (c-d, d) if c > d, or (c, d-c) if d > c. So we can reverse by subtracting the smaller from the larger.

3. Optimize with modulo

Instead of subtracting one at a time, compute how many times the smaller fits into the larger: if c > d, replace c with c % d, but ensure we don't skip past the target. Use a while loop until one coordinate equals the corresponding target coordinate.

4. Check reachability

After reducing, check if (a, b) is reached exactly. If at any point a coordinate becomes ≤ 0 or the reduction overshoots, return false. Also handle the case where one coordinate is zero: if a=0 or b=0, then (c,d) must be a multiple of the other coordinate.

5. Analyze complexity and edge cases

The modulo-based approach runs in O(log(max(c,d))) time. Discuss edge cases: a or b zero, negative inputs, and the case where (a,b) equals (c,d) initially.

Key Points to Mention

  • The problem is equivalent to the reverse Euclidean algorithm (subtractive Euclidean algorithm).
  • Use modulo to skip multiple subtractions, achieving logarithmic time complexity.
  • Both coordinates must remain positive throughout the forward process, so any non-positive input invalidates the possibility.
  • If one of the starting coordinates is zero, the other must divide the corresponding target coordinate.
  • Handle the case where (a,b) == (c,d) as trivially true.
  • Discuss time and space complexity: O(log(max(c,d))) time, O(1) space.

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

Q2

Given an array of memory requirements per task, an array of task types, and a max memory limit, find the minimum time to complete all tasks. Two tasks can run in parallel only if they share the same type and their combined memory doesn't exceed the limit. Each task takes one unit of time.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one caught me off guard because it looks like a simple greedy pairing problem but there are edge cases around tasks of the same type that still can't be paired due to memory.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Group tasks by type, then for each type, sort memory requirements and use a greedy two-pointer approach to pair the largest with the smallest possible task that fits within the limit. Count the number of pairs (each pair takes 1 unit of time) and add the number of unpaired tasks to get the total time.

Pro tip: Clarify that tasks of different types cannot run in parallel, so the total time is the sum of times for each type. Also, mention that the greedy pairing is optimal because pairing the largest with the smallest maximizes the chance of fitting two tasks together, reducing the total time.

1. Group tasks by type

Create a mapping from each task type to a list of memory requirements for tasks of that type.

2. Sort memory requirements

For each type, sort the list of memory requirements in ascending order to facilitate efficient pairing.

3. Pair tasks greedily

Use two pointers (left at smallest, right at largest) to pair the largest remaining task with the smallest possible task that fits within the memory limit. If a pair fits, increment the pair count and move both pointers; otherwise, move the right pointer left (the largest task must run alone).

4. Compute time per type

For each type, the time required is the number of pairs plus the number of unpaired tasks (which equals the total number of tasks minus the number of pairs).

5. Sum times across types

Add the times for all types to get the total minimum time to complete all tasks.

Key Points to Mention

  • Tasks of different types cannot run in parallel, so the problem decomposes by type.
  • Within a type, the goal is to maximize the number of pairs (two tasks running in parallel) to minimize total time.
  • Greedy pairing (largest with smallest that fits) is optimal for maximizing pairs.
  • Time complexity: O(n log n) due to sorting, where n is the total number of tasks.
  • Edge cases: tasks with memory exceeding the limit cannot be paired and must run alone; empty arrays; single task.
  • The total time is the sum over types of (number of pairs + number of unpaired tasks).

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