Documente Academic
Documente Profesional
Documente Cultură
Q1 Movies on Flight
You are on a flight and wanna watch two movies during this flight.
You are given int[] movie_duration which includes all the movie durations.
You are also given the duration of the flight which is d in minutes.
Now, you need to pick two movies and the total duration of the two movies is less than or equal to (d
- 30min).
Find the pair of movies with the longest total duration. If multiple found, return the pair with the
longest movie.
e.g.
Input
d: 250
Output
[90, 125]
90min + 125min = 215 is the maximum number within 220 (250min - 30min)
(2019/03/14)
https://aonecode.com/amazon-online-assessment-questions 1/7
6/26/2019 Amazon Online Assessment Questions 2019
Q2 Treasure Island
You have a map that marks the location of a treasure island. Some of the map area has jagged rocks
There are other explorers trying to find the treasure. So you must figure out a shortest route to the
treasure island.
Assume the map area is a two dimensional grid, represented by a matrix of characters.
You must start from the top-left corner of the map and can move one block up, down, left or right at a
time.
The treasure island is marked as ‘X’ in a block of the matrix. ‘X’ will not be at the top-left corner.
Any block with dangerous rocks or reefs will be marked as ‘D’. You must not enter dangerous blocks.
Other areas ‘O’ are safe to sail in. The top-left corner is always safe.
Output the minimum number of steps to get to the treasure.
e.g.
Input
[
[‘O’, ‘O’, ‘O’, ‘O’],
Output
Route is (0, 0), (0, 1), (1, 1), (2, 1), (2, 0), (3, 0) The minimum route takes 5 steps.
(2019/03/20)
Find the k post offices located closest to you, given your location and a list of locations of all post
offices available.
Locations are given in 2D coordinates in [X, Y], where X and Y are integers.
Euclidean distance is applied to find the distance between you and a post office.
Assume your location is [m, n] and the location of a post office is [p, q], the Euclidean distance
https://aonecode.com/amazon-online-assessment-questions 2/7
6/26/2019 Amazon Online Assessment Questions 2019
e.g.
Input
you: [0, 0]
post_offices: [[-16, 5], [-1, 2], [4, 3], [10, -2], [0, 3], [-5, -9]]
k=3
Output
[[-1, 2], [0, 3], [4, 3]]
(2019/05/06)
Given a binary tree, find the subtree with maximum average. Return the root of the subtree.
/ \
-2 14
/ \ / \
-1 1 5 -1
(2019/05/07)
Given a connected graph with V nodes and E edges. Find a collection of edges that connects all
nodes together without any cycle and with the minimum total edge weight.
hint: what’s the time complexity of your algorithm? Can you make the running time O(E * log(E)) by
using Union Find?
(2019/06/03)
https://aonecode.com/amazon-online-assessment-questions 3/7
6/26/2019 Amazon Online Assessment Questions 2019
In Amazon’s sort center, a computer system decides what packages are to be loaded on what trucks.
All rooms and spaces are abstracted into space units which is represented as an integer. For each
type of truck, they have different space units. For each package, they will be occupying different
space units. As a software development engineer in sort centers, you will need to write a method:
Given truck space units and a list of product space units, find out exactly TWO products that fit into
the truck. You will also implement an internal rule that the truck has to reserve exactly 30 space units
for safety purposes. Each package is assigned a unique ID, numbered from 0 to N-1.
Assumptions:
Input:
The input to the function/method consists of two arguments :
truckSpace , an integer representing the truck space.
packagesSpace , a list of integers representing the space units occupying by packages.
Output:
Return a list of integers representing the IDs of two packages whose combined space will leave
exactly 30 space units on the truck.
Example
Input :
truckSpace = 90
method should select the third(ID-2) and fourth(ID-3) package since you have to reserve exactly 30
space units.
https://aonecode.com/amazon-online-assessment-questions 4/7
6/26/2019 Amazon Online Assessment Questions 2019
(https://aonecode.com/the-coding-interview-bootcamp-algorithms-data-structures?aid=2215)
(https://aonecode.com/grokking-the-system-design-interview?aid=2215)
https://aonecode.com/amazon-online-assessment-questions 5/7
6/26/2019 Amazon Online Assessment Questions 2019
(https://aonecode.com/coding-mock-interview?aid=2215)
Top-notch Professionals
Learn from Facebook, Google, Uber senior engineers interviewed 100+ candidates.aonecode.com
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.
Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.
Free Consultation
aonecoding@gmail.com (mailto:aonecoding@gmail.com?
subject=Request%20for%20Enrollment%20AOneCode%20BootCamp&body=My%20interests%20D
esign%2FCoding%2FMock%20Interview%3B%20My%20level%20of%20experience%3B%20My%20
target%20Position)
https://aonecode.com/amazon-online-assessment-questions 6/7
6/26/2019 Amazon Online Assessment Questions 2019
https://aonecode.com/amazon-online-assessment-questions 7/7