Amazon Interview Questions
- 3of 3 votes
AnswersGiven a bst and a group of numbers g, check whether all the elements of g occur in the same path.
- thebiker925 September 12, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersGiven a BST, with nodes having a parent pointer, a pointer to a node (any node), and a value. Find the path from the given node (pointer), to the node with the given value.
- underdog December 31, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Development Manager Algorithm - 0of 0 votes
AnswersFind the first missing number in an array of sorted numbers.
- coder December 09, 2012 in United States
Eg: Input : 4,5,6,7,9,11,14,18,19
Output : 8
Expected complexity : O(log n)
Approach is similar to binary search| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
Answersfind the 2nd largest # in int array
- Itcecsa June 10, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Front-end Software Engineer Algorithm - 0of 0 votes
AnswersQ2. F2F Round-1, Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given an array of integers having the property that first that array is strictly increasing then it is strictly decreasing, You have to search for a given number.
Constraint: Minimize the complexity| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java - 1of 1 vote
AnswersQ3. Written Exam Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a singly linked list which may or may not contain loop and loop may or may not start from the head node. Count the number of elements in the linked list.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C C# C++ Coding Data Structures Java Linked Lists - 0of 0 votes
AnswersGiven an array (length n), we need to find the subarray (length k) such that the sum of the first j elements of the subarray equals the sum of the remaining (k-j) elements of the subarray.
- PM January 09, 2012 in -
For e.g.
Array: 2,2,13,4,7,3,8,12,9,1,5
Output: 4,7,3,8,12,9,1 [4+7+3+8=12+9+1]
Could this be done with a complexity better than O(n^3)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answerstwo BST were given and find the largest common bst that exists between these two
- Anonymous June 22, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou have an integer array of length N, containing values in the range 1,2,3…N^2. Sort the array in O(N) time
- Anonymous November 19, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersWrite a function to find the longest path of a tree
- mp March 22, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Trees and Graphs - 5of 5 votes
AnswersSay you have a keypad that has keys for the numbers 0 through 9 and the correct code is some sequence of 5 digits. This keypad does *not* reset after entering an incorrect sequence of 5 digits. ie. If the correct sequence is 12345, entering 7512345 will succeed in opening it because it ends in the correct sequence. If the keypad actually resets after every 5 digits pressed, then it would not succeed b/c it would interpret the above sequence as "75123" then "45".
- Jason May 30, 2015 in United States
1. Write an algorithm that will try to find the correct code for this keypad. Assume you have an API similar to KeyPad.pressKey(int n) where you pass in a number (0...9) and it returns true if the keypad unlocks and false if it's still locked.
Note that you could easily enter all digits of all numbers 00000 through 99999 resulting in 5*100000 key presses, but remember that the panel does not reset after every sequence of 5 digits, so find a way to do this more efficiently. Notice for example that entering the stream 3791283780 will test the length 5 sequences 37912, 79128, 91283, 12837, 28378, 83780; not only the two disjoint sequences 37912 and 83780.
Think of this keypad as remembering the last 4 keys pressed (and the order pressed); when the next key is pressed, if the last 4 keys + the current key equal the correct code, the keypad will unlock. Assume the keypad does all this internally, so you can just keep feeding it keypresses and it will eventually unlock if the last 5 keypresses entered is the correct code.
2. Generalize your algorithm to work for a keypad where you don't know the length of the correct sequence in advance.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 4of 4 votes
AnswersGiven a random generator rand(5) which generates numbers between 0 to 4. How do u generate numbers between 0 to 6, I.e. Implement rand(7).
- hulk April 16, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm Brain Teasers - 1of 3 votes
AnswersGiven 2 binary arrays A and B i.e. containing only 0s and 1s each of size N.
- tryingtosolvemystery August 07, 2013 in India
Find indices i,j such that Sum of elements from i to j in both arrays is equal and j-i (i.e. the length of the set i,j) is the maximum possible value.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 0of 2 votes
AnswersGiven an array of ints, find the most frequent non-empty subarray in it. If there are more than one such sub-arrays return the longest one/s.
Note: Two subarrays are equal if they contain identical elements and elements are in the same order.
- Epic_coder June 29, 2013 in United StatesFor example: if input = {4,5,6,8,3,1,4,5,6,3,1} Result: {4,5,6}
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 4of 6 votes
AnswersGive you two sequences of length N, how to find the max window of matching
- Code2Win June 08, 2013 in India
patterns. The patterns can be mutated.
For example, seq1 = “ABCDEFG”, seq2 = “DBCAPFG”, then the max window is 4. (
ABCD from seq1 and DBCA from seq2).| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer String Manipulation - 0of 0 votes
AnswersA list contains repeated numbers , all the numbers are repeated odd number of times except one which is repeated even number of time. WAP to find out that number ( which is repeated even number of times).
- maverick July 17, 2012 in India
( I gave the solution using extra space . He then asked me to give solution without extra space )| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow to check a whether a very big number n^n = k
- banerjees36 June 22, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Systems Design Engineer Algorithm Data Structures - 0of 0 votes
AnswersGiven an array find 3 elements such that a[i] < a[j] < a[k] and i < j < k in 0(n) time.
- ninja April 03, 2012 in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven a set of unique numbers from 1 to 1000, propose a data structure that allows you to perform the following operations in constant time.
- Fab February 10, 2012 in United States for Instant Video
1- Insertion,
2- Deletion,
3- Searching,
4- Get any random number.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersHow to find a first non repeating character in a String ?
- Nikhil July 21, 2011| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Java - 1of 1 vote
AnswersYou are given an array of integers(with all valid input) You have to write a function which will produce another array, where the value in each index of the array will be the product of all values in the given array accept that index.
- Azarbaizan January 10, 2017 in United States for Market Place
Example
Array 1: 1 2 3 4 5
Array 2: 120 60 40 30 24.
Come up with a solution of O(n^2) can you improve it?| Report Duplicate | Flag | PURGE
Amazon Software Engineer Arrays - 1of 1 vote
AnswersWrite program for the following scenario
- APV July 25, 2015 in India for Amazon Wireless
Input Array :- {1,2,3,4,5,5,5,6,7,7}
Output:- 5 is repeated 3 times
7 is repeated 2 times| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Arrays - 6of 6 votes
AnswersTwo container of 5 L and 3 L are given. Then are is 9.5L water given you need to make 4L water with minimum attempts and water wastage.
- Sachdefine January 11, 2014 in India for Kindle| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Brain Teasers - 0of 0 votes
AnswersDesign a DS for storing browsing history.
- Nascent April 20, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Adobe Software Engineer / Developer - 0of 0 votes
AnswersYou are given a positive integer A. The goal is to construct the shortest possible sequence of integers ending with A, using the following rules:
- Itcecsa May 02, 2012 in United States
the first element of the sequence is 1,
each of the successive elements is the sum of any two preceding elements (adding a single element to itself is also permissible),
each element is larger than all the preceding elements; that is, the sequence is increasing.
For example, for A = 42, a possible solutions is [1, 2, 3, 6, 12, 24, 30, 42]. Another possible solution is [1, 2, 4, 5, 8, 16, 21, 42].| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersThe glasses are arranged in the following order
1 2 3 4 5 6 7 8 9 10 .................... ....................
When you pour liquid into the 1st glass if it's full, then the extra liquid would be flown into the glasses 2 and 3 in equal quantities. When glass 2 is full, the extra liquid would be flown into 4 and 5 and so on.
- manjunath426jc December 28, 2011 in India
Given an N liters of liquid and capacity of each glass is C and the number of levels of glasses is L. Give the amount of liquid present in each glass if you empty N liters of liquid by pouring into glass 1.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Data Structures - 0of 0 votes
AnswersGiven an array of integers for each elemnt in the array find the closest greatest elemnt to the right.
- Guest August 22, 2011
Closest means the distance beteen two elements array indices must be miminim . can it be done better 0(n2) ?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHow to find the missing K elements out of the unsorted natural N elements in an integer array.
- Novice June 07, 2010
Time complexity has to be O(n), with 3 extra variables of Space.
One suggestion was to do it in-place in the array.
Is there exists an in place countsort kind of method?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
Answersgiven a number round it off to next power of 2.
- Chop December 29, 2009
eg: if given 3 it should return 4,
if given 5 it should return 8.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm