Amazon Interview Questions
- 0of 0 votes
AnswersDifference is Minimum
- manu January 31, 2011
Algorithm to find the two numbers whose difference is minimum among the set of numbers.
For example the sequence is 5, 13, 7, 0, 10, 20, 1, 15, 4, 19
The algorithm should return min diff = 20-19 = 1.
Constraint - Time Complexity O(N) & Space is not a constraint [upto O(3N)]
Assumption - Sorting O(nlogn) & comparison of adjacent numbers is already known & is not an option. Try to keep it linear| Report Duplicate | Flag | PURGE
Microsoft Amazon Software Engineer / Developer Software Engineer in Test Algorithm - 0of 0 votes
AnswersGiven two log files, each with a billion usernames (each username appended to the log file), find the usernames existing in both documents in the most efficient manner? Use pseudo-code or code. If your code calls pre-existing library functions, create each library function from scratch.
- dotNet February 20, 2006| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding Algorithm Object Oriented Design - 0of 0 votes
AnswersGiven two sorted arrays A and B that may have repeated elements. Form a new sorted array C that contains the elements of A and B [Condition : You are not allowed to merge the two arrays and then sort. ]
- nidhi.prakash.410 January 23, 2017 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer - 0of 0 votes
Answersgiven a string, calculate the frequency of characters, output the array with the letter and frequency. (such as: for “abbcdc”, the output should be (a,1),(b,2),(c,2),(d,1))
- eminsqa January 26, 2016 in United States for AmazonMusic| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Quality Assurance Algorithm Java - 0of 0 votes
AnswersHow to find non- common elements between two string arrays. Eg: String a[]={"a","b","c","d"};
- ananth.gorthi August 24, 2014 in India
String b[]={"b","c"};
O/p should be a,d| Report Duplicate | Flag | PURGE
Amazon SDE-2 Java - 2of 2 votes
AnswersYou are given an array of both negative and positive integers. You need to rearrange the array such that positive and negative numbers alternate. Also, the order should be same as previous array and only O(1) auxiliary space can be used and time complexity boundation O(n).
- peechus July 29, 2014 in United States
eg. -2 3 4 5 -1 -6 7 9 1
result – 3 -2 4 -1 5 -6 7 9 1.| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersGiven two String, s1 and s2.
- niraj.nijju October 15, 2013 in India
to find the longest substring which is prefix of s1, as well as suffix of s2.| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 2 votes
AnswersGiven a BST, print the node with value between [min, max], i.e. min = 10, max = 17, print the node with value between 10 and 17
- bskb.good February 23, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersGiven an array elements, Find the maximum number which can be formed by the array elements
- bcsandy.1982 February 17, 2013 in India for Kindle
Eg input – a[ ] = {9,6,8,1]
Output - 9861| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 0of 0 votes
Answers: Design a data structure for the following operations:
- Nascent August 26, 2012 in India
I. Enqueue
II. Dequeue
III. Delete a given number(if it is present in the queue, else do nothing)
IV. isNumberPresent
All these operations should take O(1) time| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite an algorithm to find F(n) the number of bits set to 1, in all numbers from 1 to n for any given value of n.
- xiaoc10 March 21, 2012 in United States
Complexity should be O(log n)
For example:
1: 001
2: 010
3: 011
4: 100
5: 101
6: 110
So
F(1) = 1,
F(2) = F(1) + 1 = 2,
F(3) = F(2) + 2 = 4,
F(4) = F(3) + 1 = 5,
etc.
I can only design an O(n) algorithm.| Report Duplicate | Flag | PURGE
Amazon Algorithm - 0of 0 votes
AnswersDesign an algorithm to find all elements that appear more than n/2 times in the list. Then do it for elements that appear more than n/4 times.
- vikas tandi August 14, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 7of 7 votes
AnswersFind missing element in the A.P.
- poojaarora014 December 22, 2015 in India| Report Duplicate | Flag | PURGE
Amazon SDET Algorithm - 1of 1 vote
AnswersFind the second most repeating number in an array without using extra storage. (I had given solution using a hash table)
- xyz_coder April 02, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Intern - 6of 6 votes
AnswersIn a certain language which has same alphabets as in english language (ie. a-z), but the order of the alphabets is different (for eg 's' is the first character, 'g' is second, and likewise). Given a dictionary of this new language (which has words arranged according to new alphabetical order), FInd out the order of alphabets in this language.
- sgarg June 09, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Google SDE1 Software Engineer / Developer SDE-2 Algorithm - 0of 0 votes
AnswersGiven an array find the next greatest element to the right of it. [4, 5, 2, 25]
- firefox April 02, 2013 in United States
Element NextGreatestElement
4 --> 5
5 --> 25
2 --> 25
25 --> -1
i gave o(n^2), but was
asked to solve in o(n)..You can take extra space...| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersHow will you remove duplicate characters in a string
- enthusiast November 15, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm - 0of 0 votes
AnswersFind preorder successor in BST.
- ninja July 07, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon - 0of 0 votes
Answersinput linked list is : 1->9->3->8->5->7->7
- ashish April 10, 2012 in India for hyderabad
do you see any pattern in this input ?
odd placed nodes are in increasing order and even placed nodes are in decreasing order.
write a code that gives the the following linkedlist:
output linked list should be 1->3->5->7->7->8->9
?? can it be done inplace ?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Linked Lists - 0of 0 votes
AnswersIf there is a n-digit, print the digits one by one without using temporary storage and how will you do it efficiently?
- javacode7 October 07, 2011 in United States
Example:
if the number is 1054
print:
1
0
5
4| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersJump Game:
- Anonymous August 10, 2011
Given an array start from the first element and reach the last by jumping. The jump length can be at most the value at the current position in the array. Optimum result is when u reach the goal in minimum number of jumps.
For ex:
Given array A = {2,3,1,1,4}
possible ways to reach the end (index list)
i) 0,2,3,4 (jump 2 to index 2, then jump 1 to index 3 then 1 to index 4)
ii) 0,1,4 (jump 1 to index 1, then jump 3 to index 4)
Since second solution has only 2 jumps it is the optimum result.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersThere is a doubly linked list with next pointer and arbitrary pointer( points to an arbitrary node in list). You have to make a copy of the linked list and return. In the end original list shouldn't be modified. Best time O(n).
- cracker April 06, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Linked Lists - 0of 0 votes
AnswersA special type of tree is given, Where all leaf are marked with L and others are marked with N. every node can have 0 or at most 2 nodes. Trees preorder traversal is given give a algorithm to build tree from this traversal.
- mail2maulish January 10, 2011| Report Duplicate | Flag | PURGE
Amazon Trees and Graphs - 0of 0 votes
Answersfind LCA (lowest common ancestor) for non binary tree.
- Anonymous October 23, 2009| Report Duplicate | Flag | PURGE
Amazon Microsoft Software Engineer / Developer Algorithm Trees and Graphs - 0of 0 votes
AnswersFind the longest running positive sequence in an array -
- coderhacker April 15, 2015 in United States
Eg - [1,2,-3,2,3,4,-6,1,2,3,4,5,-8,5,6]
It should return 5, with start index : 8| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 4of 4 votes
AnswersTwo finite, strictly increasing, integer sequences are given. Any common integer between the two sequences constitute an intersection point. Take for example the following two sequences where intersection points are
- blackfever June 29, 2014 in India
printed in bold:
First= 3 5 7 9 20 25 30 40 55 56 57 60 62
Second= 1 4 7 11 14 25 44 47 55 57 100
You can ‘walk” over these two sequences in the following way:
1. You may start at the beginning of any of the two sequences. Now start moving forward.
2. At each intersection point, you have the choice of either continuing with the same sequence you’re currently on, or switching to the other sequence.
The objective is finding a path that produces the maximum sum of data you walked over. In the above example, the largest possible sum is 450 which is the result of adding 3, 5, 7, 9, 20, 25, 44, 47, 55, 56, 57, 60, and 62
this is the same problem which I saw in SPOJ Problem Set| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 0of 0 votes
AnswersYou are given an array of N elements. Each element in the range Min of int to Max of Int. You need to find the length of longest sequence in this array such that difference of largest and smallest element of that sequence is 1. The sequence need not be sequential.
- northernlight May 06, 2014 in United Kingdom
For e.g. array[]={6,10,6,7,8,9,0}
seq {6,10} = diff is 4 len 2
seq { 10,7,8} diff is 3 len 3
seq { 7,8,9} diff 2 len 3
seq {6,6,7} diff is 1 len 3
In this example the program should return 3 .
Complexity N*longN| Report Duplicate | Flag | PURGE
Amazon Algorithm Arrays C C++ - 0of 2 votes
AnswersGiven an array say [0,1,2,3,5,6,7,11,12,14,20]
- i_learn April 11, 2014 in India
given a number say 5.
Now find the sum of elements which sum to 5
eg:2+3=5, 0+5=5 etc.
I guess the interviewer wanted all possible combinations eg 0+2+3=5, etc| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance Algorithm Android Application / UI Design Arrays Coding Data Structures Dynamic Programming Perl Sorting test Testing