Amazon Interview Questions
- 2of 2 votes
AnswersWrite program for the following case
- APV July 25, 2015 in India for Amazon Wireless
Reverse string (string is stored in an array)
Input:- "This is an example"
Output:-sihT si na elpmaxe| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer String Manipulation - 2of 2 votes
AnswersWrite a method that multiplies two integers without using multiply operator
- S.Abakumoff February 25, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWrite a function which compress string AAACCCBBD to A3C3B2D
- kishore February 18, 2013 in United States| Report Duplicate | Flag | PURGE
Amazon Software Development Manager Algorithm - 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 - 2of 2 votes
Answers(Bar Raiser Round)
- gdg June 26, 2014 in United States
Divide the array(+ve and -ve numbers) into two parts such that the average of both the parts is equal.
Input:
[1 7 15 29 11 9]
Output:
[15 9 1 7 11 29]
Explanation:
The average of first two elements is (15+9)/2 = 12, average of remaining elements is (1+7 +11 +29)/4 = 12| Report Duplicate | Flag | PURGE
Amazon Arrays - 2of 2 votes
AnswersYou are given an array with numbers - [11, 3, 11, 11, 3, 2, 0, -2, 2]
- KevinK February 27, 2014 in United States
You are supposed to write a function that returns the number that appears "odd" number of times.
The solution is obviously using HashMap. But that takes O(n) to create the HashMap and O(n) to lookup. How can one eliminate the second O(n) yet keeping the HashMap?
Hint: Do you really need to count frequency of occurrence of each digit?| Report Duplicate | Flag | PURGE
Amazon Principal Software Engineer Arrays - 2of 2 votes
AnswersGiven an array of integers . Write an algorithm to find all the Pythagorean triples.
- Raj August 31, 2013 in India
Eg : i/p : int arr[ ] = {1,3,4,5,6,7,8,10,11}
o/p: Print 3,4,5 and 6,8,10| Report Duplicate | Flag | PURGE
Amazon - 2of 2 votes
AnswersGiven some resources in the form of linked list you have to canceled out all the resources whose sum up to 0(Zero) and return the remaining list.
- ganesh.eng2015 July 24, 2016 in India
E.g-->> 6 -6 8 4 -12 9 8 -8
the above example lists which gets canceled :
6 -6
8 4 -12
8 -8
o/p : 9
case 3 : 4 6 -10 8 9 10 -19 10 -18 20 25
O/P : 20 25| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
Answersyou have given 2n+1 numbers in which 2n numbers are repeated means every number is having duplicate value.find that non repeating number in constant space and o(n) time.i told him using XOR.
- time February 03, 2012 in India
then he gave me 2n+2 numbers in which 2n numbers are repeating like above now you have 2 different number.find both number in constant space and o(n) time.(f2f 4th round)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven a sorted array with only 0's and 1's.Count the number of 0's.
- steelrahul June 16, 2015 in India for Hyderabad
e.g: 0 0 0 0 1 1
Ans: 4.| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
Answersint sum = 0;
- nirupam.astro January 04, 2014 in India
for (int i = 0; i < m; i++)
for (int j = i + 1; j < n; j++)
for (int k = j + 1; k < l; k++)
sum++;
what will be the value of sum?| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 2of 2 votes
AnswersWrite a code to test whether string s2 is obtained by rotating the string s1 by 2 places.
- Surekhag28 July 26, 2014 in India for Kindle
e.g S1="amazon" S2="azonam" return true
S1="quality" S2="lityqua" return false| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 2of 2 votes
AnswersGiven nxn boolean matrix (0's and 1's) .
- thebiker925 September 11, 2013 in United States
Find out whether there exist a row i and column j such that
1) all elemets of row i are zero's and
2) all elements of column j are 1's and
3)(i,j)th entry of the matrix can be either 0 or 1
Find out such a i and j exist or not .
complexity :O(n)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWrite a method to count the number of 2s between 0 and n.*
- xankar May 12, 2016 in United States| Report Duplicate | Flag | PURGE
Amazon Software Developer Coding - 2of 2 votes
AnswersAssume I have a log file with list of people with their arrival and departure time at an event that happened in the past.
- Bevan March 02, 2013 in United States
My task is to find out the maximum number of people present at any time during the entire event? I am not given query time.
ai = Arrival time of person i
di = Departure time of person i
I have a list of pairs like (a1,d1), (a2,d2), (a3,d3).... (an,dn)... It's not in a database.
I apologize as I cannot edit my previous question. I think it had a incomplete description.
Please let me know if you guys still need clarification. Thanks| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersVerify if S2 = {5,8,2} is a subset of S1 = {1,5,4,6,8,2} and S3 = {5,8,2,7} is not a subset of S1.
- hadeebataj May 10, 2019 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer String Manipulation - 2of 2 votes
AnswersGiven two strings, return true if they are one edit away from each other, else return false. An edit is insert/replace/delete a character.
- codewarrior September 07, 2015 in United States
Ex. {"abc","ab"}->true, {"abc","adc"}->true, {"abc","cab"}->false| Report Duplicate | Flag | PURGE
Amazon SDE1 - 2of 2 votes
AnswersAn array consist of elements whose difference is positive or negative 1. I have to find the given elements without using linear search.
- thilaksmile June 15, 2015 in India
Say
Int arr[]={1,2,3,4,3,4,5,6,7
To find : 6
.
Please provide some one code/algorithm for this problem.| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer - 2of 2 votes
AnswersGiven an array of strings with only lowercase letters , create a function that returns an array of those same strings, but each string has its letters rearranged such that it becomes a palindrome (if possible, if not, return -1)
- makingworldcode September 13, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Java Developer Java - 2of 2 votes
AnswersWrite a function, for a given number, print out all possible way to make up that number eg: 2 - 1 1,2
- sLion May 25, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon SDE-2 Algorithm - 2of 2 votes
AnswersIn an array of unsorted integers (you may assume the array may contain +ve, -ve and 0s), write a function
- Jeanclaude June 28, 2013 in United States
int returnNthMax(int[] arr, int n)
which will return the nth Max number. For e.g. if this is given array {2, -4, 5, 6, 0, 7, -1, 10, 9} and n=1, it should return the max number, 10 and if n=3, it should return 3rd max number, which is: 7.| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Arrays - 2of 2 votes
AnswersThere is a large file( 1TB) containinig braces. Question is to check for their balance. I said will use a counter, will increment on an open brace and decrement on an close brace. If counter goes negative or counter is non zero at the end of the file, braces are not balanced. Otherwise balanced. Followup question was to make this process parallel ( meaning to see if this problem can be solved through parallelism, like dividing the the problem into sub problem....) Remember the file is very large.
- gns January 23, 2014 in India| Report Duplicate | Flag | PURGE
Amazon SDE1 Problem Solving - 2of 2 votes
Answersc program to find square root of an interger without using in built functions
- saran August 12, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Intern C - 2of 2 votes
AnswersOutput the leftmost element of each level of a tree
- 3139a1m August 01, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Intern - 2of 2 votes
AnswersConsider a city (visualize a circle). It has n petrol stations in it. You are given the maximum amount of petrol that can be filled at each of these stations. You are also given the distance between one station to the next one. The aim is to cover the entire city and come back to the start point. Assume that 1 liter of petrol will last for 1km.
- D March 27, 2013 in India
Q: List out all the possible petrol stations from where the journey can be started, so as to cover the city.| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Algorithm - 2of 2 votes
AnswersA string can contain 0 to n(input) number in sorted form find all the transition point.
- Nascent June 07, 2014 in India| Report Duplicate | Flag | PURGE
Amazon - 2of 2 votes
AnswersWrite a Java code that take a string of parenthesis as input and return if the string is valid or not . The input will have '(' and ')' and also '*' and * serves as wild card and can be used in place of both '(' and ')' or it can be null.
- ryanray1512 October 16, 2017 in United States
For example,the String (*)(*)(** is a valid String.
Follow up: What if '[]' and '{}' are also in the string along with '()' and * can be used in place of any of them or can be considered as null?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 2of 2 votes
AnswersCalculate number of zeros in a given integer.
- test222 March 29, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Bit Manipulation - 2of 2 votes
Answers"Given an array of strings, find the string which is made up of maximum number of other strings contained in the same array.
- mail.kshitij.jain October 10, 2013 in India
e.g. “rat”, ”cat”, “abc”, “xyz”, “abcxyz”, “ratcatabc”, “xyzcatratabc”
Answer: “xyzcatratabc”
“abcxyz” contains 2 other strings,
“ratcatabc” contains 3 other strings,
“xyzcatratabc” contains 4 other strings"| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm