Sunteți pe pagina 1din 7

6/26/2019 Amazon Online Assessment Questions 2019

Amazon Online Assessment Questions


2019

Amazon Online Assessment 2019

Amazon OA2 Questions 2019

Updated by James on 2019-06-05

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

movie_duration: [90, 85, 75, 60, 120, 150, 125]

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

and dangerous reefs. Other areas are safe to sail in.

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.

You cannot leave the map area.

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’],

[‘D’, ‘O’, ‘D’, ‘O’],


[‘O’, ‘O’, ‘O’, ‘O’],

[‘X’, ‘D’, ‘D’, ‘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)

Q3 K Nearest Post Offices

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

between the office and you is SquareRoot((m - p) * (m - p) + (n - q) * (n - q)).



K is a positive integer much smaller than the given number of post offices.

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)

Q4 Subtree: Maximum Average Node

Given a binary tree, find the subtree with maximum average. Return the root of the subtree.

Example Given a binary tree:

/ \

-2 14

/ \ / \

-1 1 5 -1

return the node 14.

(2019/05/07)

Q5 MST: Minimum Spanning Tree

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)

Q6 Amazon’s Sort Center

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:

You will pick up exactly 2 packages.


You cannot pick up one package twice.
If you have multiple pairs, select the pair with the largest package.

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

packagesSpace = [1, 10, 25, 35, 60]


Output :
[2, 3]
Explanation : Given a truck of 90 space units, a list of packages space units [1, 10, 25, 35, 60], Your

method should select the third(ID-2) and fourth(ID-3) package since you have to reserve exactly 30
space units.

CHECK OUT OTHER AMAZON OA 2 QUESTIONS 2019

More Amazon OA updates are on the way. Follow us....



.

https://aonecode.com/amazon-online-assessment-questions 4/7
6/26/2019 Amazon Online Assessment Questions 2019

Get one-to-one training from Google Facebook engineers


(https://aonecode.com/#courses)

(https://aonecode.com/the-coding-interview-bootcamp-algorithms-data-structures?aid=2215)

One-on-One Algorithm and Coding Training

(https://aonecode.com/grokking-the-system-design-interview?aid=2215)

One-on-One System Design Training

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)

One-on-One Mock Interview

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.

Customized Private Class

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/ (https://aonecode.com/ (https://aonecode.com/


airbnb-interview- google-interview- facebook-interview-
questions) questions) questions)

Airbnb Coding Interview Google Coding Interview Facebook Coding

Questions Questions Interview Questions

(https://aonecode.com/ (https://aonecode.com/ (https://aonecode.com/


amazon-interview- linkedin-interview- uber-interview-
questions) questions) questions)

Amazon Coding Interview Linkedin Coding Interview Uber Coding Interview

Questions Questions Questions

Copyright © A++ Code Bootcamp 2019

https://aonecode.com/amazon-online-assessment-questions 7/7

S-ar putea să vă placă și