Amazon OA Coding Questions 2025

amazon logo
amazon
sde 1nullnull
August 21, 20257 reads

Summary

Interviewed for Amazon SDE 1 role. Faced two challenging coding problems during OA. First problem involved finding minimum cost to convert all products to variant A with specific operations. Second problem required minimizing inconvenience in a grid by strategically placing a new delivery center. Both problems required advanced algorithmic thinking and efficient solution strategies.

Full Experience

Recently completed Amazon's Online Assessment for the SDE 1 position. The OA consisted of two complex coding problems that tested both algorithmic knowledge and problem-solving skills. The first problem, Minimum Cost to Convert Products, required determining the optimal way to convert all elements in an array to 0 with specific operations, balancing cost and efficiency. The second problem, Minimize Inconvenience of Delivery Centers, involved a grid where the goal was to reduce the maximum distance from any 0 cell to the nearest delivery center by flipping at most one 0 to 1. Both problems demanded a deep understanding of data structures and algorithms, as well as careful planning for optimal solutions.

Interview Questions (2)

Q1
Minimum Cost to Convert Products
Data Structures & AlgorithmsHard

You are given an array product[] of size n, where each element is 0 or 1.

1 = variant B (needs to be converted)
0 = variant A (already correct)

Amazon wants to convert all products into variant A (0).

You are allowed to choose a subarray of length = k, and set exactly one element in that subarray to 0.
The cost of an operation = sum of values in that subarray before conversion.

Return the minimum cost to make the entire array all 0.

Q2
Minimize Inconvenience of Delivery Centers
Data Structures & AlgorithmsHard

A city is represented as a grid:

Delivery centers are marked as 1
All other places are marked as 0

The distance between two cells is defined as d((x1,y1), (x2,y2)) = max(|x1-x2|, |y1-y2|).

The inconvenience of the grid is the maximum distance of any 0 from its nearest delivery center.

Amazon is planning to open one new delivery center. You may flip at most one 0 to 1.
Find the minimum inconvenience possible after this operation.

Preparation Tips

Prepared by focusing on algorithmic problem-solving techniques, particularly for dynamic programming and greedy algorithms. Worked on similar problems to understand the optimal approaches for handling large input sizes. Also, practiced multi-source BFS for grid-based problems to tackle the second question effectively.

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!