Amazon Interview Questions
- 0of 0 votes
AnswerGive an N-length array with only 0 and 1 inside
- ajay.raj May 01, 2018 in United States
Requires to find the minimum number of conversions needed to convert the array to 0 before all 1.
The conversion is to change a 0 to 1 or a 1 to 0,
And the number of 0 and 1 in the converted array can be arbitrary.
Just find the minimum conversion step| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersTo an array and K, each element in the array can only move K positions to the left at most, no limit to the right, try to sort the array under the limit of K
- ajay.raj April 10, 2018 in United States
a = [5, 2, 4, 3, 1], k = 2
Return [2, 3, 1, 4, 5]| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven a function rand32() (random number range 0-2**32-1) that randomly generates a 32-bit int, design a new random function:
- ajay.raj April 09, 2018 in United States
Randn(n) generates a random distributed random number (0 - 2**n-1)
Rand3n(n) generates (0 - 3**n-1) the uniformly distributed random number| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswerTopic: There is a set of coordinates. The original format of each coordinate is (1.3, 0.5). However, the comma and decimal point are gone. Only one string is left, allowing you to restore all possible combinations. For example, 123, possible (1, 23) (1, 2.3) (12, 3) (1.2, 3)
- ajay.raj April 09, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersImplement a method to check if a n-ary tree is unival
- ajay.raj April 04, 2018 in United States
class TreeNode {
int val;
List<TreeNode> children;
TreeNode(int val) {
this.val = val;
children = new ArrayList<>();
}
}| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven the length and width of a rectangle, how many ways can be used to go from the upper left corner to the upper right corner (each step can only go to the right, top right or bottom right):
- ajay.raj April 03, 2018 in United States
-follow up 1: If three points in the rectangle must be visited, how many ways
-follow up 2: If you are given an point H, and the path must go down below the H point, how to do it| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersThe thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that "all houses in this place forms an n-nary tree". It will automatically contact the police if two directly-linked houses were broken into on the same night.
- ajay.raj March 31, 2018 in United States
Determine the maximum amount of money the thief can rob tonight without alerting the police.
/**
* Definition for a n-ary tree node.
* public class TreeNode {
* int val;
* List<TreeNode> kids;
* }
*/
class Solution {
public int rob(TreeNode root) {
}
}| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answerspreorder Traversing a n-ary tree without using recurrsion
- ajay.raj March 31, 2018 in United States
TreeNode<T> {
T val;
List<TreeNode> children;
}| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven two methods for the person class, one to find a dad and one to find a mother, using these two methods to achieve a method to determine whether the two people are related to blood, assuming a limited number of people.
- ajay.raj March 30, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersSelf-implemented data structures and methods, output all the heirs. To achieve birth (parent, name), dead (name), getAllSucession (). There is a king, you can use birth plus children, dead dead. The order of inheritance is the same as preorder except that this tree has multiple children.
- ajay.raj March 30, 2018 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersGiven a binary matrix, find if there is a path from the upper left corner to the lower right corner, meet the conditions each time the value of the cell must be different.
- ajay.raj March 06, 2018 in United States
Follow up if there is a path with the same number of 0 and 1?| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswerThere are three threads and we want them to run
- ajay.raj March 05, 2018 in United States
one after the other. How can we do that?| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersIn a grid, you are given a position, and every location has some value.
- ajay.raj March 05, 2018 in United States
find the shortest length so that you can touch to any boundary of the grid.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersYou are given a graph and an algorithm that can find the shortest
- ajay.raj March 05, 2018 in United States
path between any two nodes
Now you have to find the second shortest path between same two nodes.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswerFind product of distinct prime
- ajay.raj March 05, 2018 in United States
factor of all numbers .
Ex
10
12
7
prime factor of 10 = 2*5
prime factor of 12 = 2*2*3
prime factor of 7 = 7
SO distinct prime factor is 2*5*3*7 = 210| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answersencode binary in bytes is to give a matrix of size M * N,
- ajay.raj March 05, 2018 in United States
This matrix is encoded in bytes as a 4 * 4 bool matrix
[0 0 0 0
1 0 0 1
0 0 0 0
0 0 0 1]
Will be encoded as a byte array [9, 1].
Then write a function set_one (vector <byte> arr, int M, int N, int start_row, int start_col, int end_row, int end_col);
Set all of 0 from (start_row, start_col) to (end_row, end_col) to 1
for example
start_row = 1
start_col = 2
end_row = 2
end_col = 0,
Just that 4 * 4matrix will become
[0 0 0 0
1 0 1 1
1 0 0 0
0 0 0 1]
The byte array after encode should be rewritten as [11, 129].| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answersfind out all of the state machine will guaranteed to come to safe state
- ajay.raj March 05, 2018 in United States
ex
A -> [B, C, D, E]
B -> [A]
C -> [D, E]
D -> [E].
E -> [safe state]
Output [C, D, E] because once these states will eventually go to safe state| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
Answers/*Coding question: The customers for a particular business, required to use a webpage to select a Browse Node.
- pragramticProgrammer February 22, 2018 in United States
A Browse Node, is an element in the classification structure used to classify products in the Amazon webpage.
The products are classified in 8 categories. Each category has its own sub-classification that looks like a tree with many
children per node and many levels. The UI developer has a tool to paint such tree. He requires from you (You are the backend developer)
to implement 2 interfaces for him:
Node getRoot();
List<Node> getChildren(Node node);
The data is available for you in a text file with this format:
//nodeid, parent_node_id, nodename
Example:
//nodeid, parent_node_id, nodename
10, 1, Comedy Books
20, 2, Tablets
1, -1, Books
11, 1, Novels
12, 11, Terror novels
2, -1, Electronics
-1, 0, GlobalRoot
*/| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 0of 0 votes
AnswersMinimum Continuous Subsequence: targetList & availabletTagsList are two lists of string.
- pragramticProgrammer January 31, 2018 in United States
Input:
targetList = {"cat", "dog"};
availableTagsList = { "cat", "test", "dog", "get", "spain", "south" };
Output: [0, 2] //'cat' in position 0; 'dog' in position 2
Input:
targetList = {"east", "in", "south"};
availableTagsList = { "east", "test", "east", "in", "east", "get", "spain", "south" };
Output: [2, 6] //'east' in position 2; 'in' in position 3; 'south' in position 6 (east in position 4 is not outputted as it is coming after 'in')
Input:
targetList = {"east", "in", "south"};
availableTagsList = { "east", "test", "south" };
Output: [0] //'in' not present in availableTagsList
Note: targetList will contain Distinct string objects.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are given with a large paragraph and N words.
- avi007 January 09, 2018 in India
You have to find a min length subparagraph of the paragraph which contain all those N words in any order. Here length of a paragraph is the count of words in the paragraph.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersGiven a binary tree, how do you serialize and deserialize. Remember it is not BST it is a general binary tree which can also have duplicate elements.
- agrawal.arpit35 August 22, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersFind the largest repeating sub-string in a string.
- Constantine August 22, 2017 in United States
ex: banana
ans is: ana| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersDesign Distributed Web Crawler.
- hprem991 August 01, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon SDE1 - 1of 1 vote
AnswersThere is a conference room. N people are joining the conference. You have the start time and end time of each of them visiting it. You are asked to determine the maximum number of people that can be inside the room.
- Raje July 17, 2017 in India
Example – Four people are visiting the conference
Person A B C D
Start (hour) 1 3 2 5
End (hour) 4 5 7 10
Answer will be – 3| Report Duplicate | Flag | PURGE
Amazon SDE1 dp , matrix ,recursion , flipkart - 0of 0 votes
AnswersGiven transactions between group of friends. How to minimize the number of transactions by eliminating redundant cash flow paths?
- imrohitkhatri June 29, 2017 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswerDesign a suggestions list [system design] for words starting with prefix that user has typed on kindle device . The search is based on most frequent item occurring at the top to least frequent item at the bottom. Most frequent item depends on the usage of word globally.
- disaster007 June 27, 2017 in United States for Prime
For e.g user types "dra" . There should be a list of suggestions starting with dra such as dragon, drape, dracula etc based on their frequency of usage.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersDesign a image slide show 1) put image method 2) get image 3) random method. Random method should return a list of images such that images should be in randomized order and no image should be displayed twice without exhausting all images at once. I used list to store images . I used random class to generate randomly generated images based on the interval {0,list.size()}. But he insist on using randomization without depending on the list size.
- disaster007 June 27, 2017 in United States for Prime| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswerGiven a set of points in a plane, determine the position/angle where a yacht of 30 degree angle could be placed such that it could cover maximum points
- disaster007 June 27, 2017 in United States for Prime| Report Duplicate | Flag | PURGE
Amazon SDE1 - 0of 0 votes
AnswersShell command, there is a log file, you want all the "error" inside the line to find out into another file inside,
- ajay.raj June 11, 2017 in United States
What instruction,| Report Duplicate | Flag | PURGE
Amazon SDE1