Amazon Interview Questions
- 1of 1 vote
Answers3. Implement a function that returns the i-th most popular item sold at Amazon. You cannot rely on any libraries.
- laurentr September 18, 2015 in United States
class Item {
String itemId;
int quantitySold;
}
/**
* Find the ith most popular item in the list.
*/
String find(List<Item> items, int i) {
// your code goes here
}| Report Duplicate | Flag | PURGE
Amazon Software Developer - 1of 1 vote
AnswersIn basket ball game for a player to win a game
- Aspire November 13, 2014 in United States
challenge 1) 2 out of 3 throws should be basket
challenge 2) 5 out of 8 throws should be basket
which challenge should the player choose so that he might have better chance of winning the game?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Probability - 1of 1 vote
AnswersWrite a program to evaluate arithmetic/math expression
- focus March 25, 2014 in United States
"12 + 5*4 + 26" = 58
"5 * 4" = 20
"6 + 4" = 10
"12" = 12| Report Duplicate | Flag | PURGE
Amazon Algorithm - 1of 1 vote
AnswersGiven an integer array find all pythogorean triplets. a^2 + b^2 = c^2 print the a,b,c and their indexes
- avinash January 20, 2014 in India for Global Payment Services| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 1of 1 vote
AnswersIn a sorted array of 0's and 1's ,find the first occurrence of a 1 in it....
- psp.reachable@gmail.com October 13, 2008
eg:
000111111111
must return 4| Report Duplicate | Flag | PURGE
Amazon Development Support Engineer Algorithm - 1of 1 vote
AnswersHow to find if a given expression is a valid arithmetic expression?
- testsync012345 October 23, 2015 in United States
Eg:(())()) - Invalid expression, (()()) - Valid expression| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Data Structures - 1of 1 vote
AnswersHow will you design, and what data structure will you use for a contact list in a cell Phone. It should support insert/modify/delete/search functionality like that provided in a cell phone.
- anurag6989 August 21, 2014 in India
Suppose some of the entries are
Aman
Amazon
Neha Aman
and we type 'ama'
then the result should show all the above three enteries.
Also it should be possible to search using phone numbers.| Report Duplicate | Flag | PURGE
Amazon SDE-2 Data Structures - 1of 1 vote
AnswersFind the largest sequence in a array which sums to zero
- ASimpleCoder May 10, 2014 in India| Report Duplicate | Flag | PURGE
Amazon - 1of 1 vote
AnswersThere are n items and length of each item is b. Different bar codes written on item consist of only 0's and 1's. We need to put items in the bag but with a condition. Most of the bar codes differ only in 1 or 2 bits. So we can only put an item into other bag if it has more than 2 differing bits from all the other items of that bag.
- ahall1006 September 30, 2013 in United States
Find no. of bags needed.
INPUT :
First line contains two space separated integers, N and B.
N : no of items to be carried, B : length of each bar code.
Next N lines each contain B space separated integers (0's and 1's only) denoting Bar Code of corresponding items.
OUTPUT :
Minimum no. of bags required.
CONSTRAINTS :
1 <= N <= 10,000
1 <= B <= 32
Example:
INPUT:
5 6
1 1 1 1 1 1
0 0 0 0 1 0
1 1 0 0 0 1
1 1 1 0 0 0
1 0 0 0 0 0
OUTPUT:
2
EXPLANATION :
1st item has more than 2 bits differing from rest of all the items so it is in Bag 1.
2nd and 5th item have 2 bits differing so they can be grouped together.
3rd and 4th are also having only 2 differing bits so they can also be put into the same bag.
5th is having only 2 differing bits with all others but 1st, so 2,3,4,5 are all grouped together in Bag 2.| Report Duplicate | Flag | PURGE
Amazon Algorithm - 1of 1 vote
AnswersYou are given a UNIX path with dot (current) and two dots (parent). Convert this to an absolute path
- JSDUDE April 30, 2013 in United States
E.g. $/home/abc/.././def/./ghi/../.
becomes $/home/ghi/| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test String Manipulation - 1of 1 vote
AnswersYou are given two array lists. One Array List contains information of latitudes and longitudes of all the amazon stores and another array list contains all the possible values of latitudes and longitudes. Find an optimal way to find out all the latitudes and longitudes which are nearest to one pair of amazon store.
- fly123 February 02, 2013 in United States
ArrayList<latitude, longitude> AmazonStore;
ArrayList<latitude, longitude> World;| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 1of 1 vote
AnswersClassic 2-sum problem.
- laprovence27 January 18, 2013 in United States
Hint, using hash table.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 1 vote
AnswersGiven an array of 999 distinct integers ranging from 1 to 1000 including. Find which number is missing. Restrictions: loop over the array only once, can't allocate an additional array.
- Garry November 06, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven two strings, print all the inter-leavings of the Strings in which characters from two strings should be in same order as they were in original strings.
- mrityunjay21 July 26, 2016 in United States for Payments
e.g.
for "abc", "de", print all of these:
adebc, abdec, adbce, deabc, dabce, etc, etc| Report Duplicate | Flag | PURGE
Amazon SDE-2 Behavioral - 1of 1 vote
AnswersAn employee class has id, name and a vector of employees who reports him. Given two employees find the common manager of them.CEO pointer is provided.
- rsl October 10, 2015 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 1of 1 vote
AnswersDesign a data structure to keep track of top k elements out of 2 billion records.
- panda April 22, 2015 in India
Each record is numberd with a key which is 30 bit and a number which is count of how many times the customer has visited us.
Come up with an data structure so that the updation of element in 2 billion records will be faster.
Getting top k element will be faster| Report Duplicate | Flag | PURGE
Amazon SDE1 Data Structures - 1of 1 vote
AnswersWrite a program to find the smallest number that can be formed by 0 and 9 which is divisible by a given number.
- Shaziya Syeda September 22, 2014 in India
For example, if given number is 3 output should be 9,
if given number is 2 output is 90,
if given number is 10 output is 90,| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm - 1of 1 vote
AnswersIn Amazon web site, the product items has to show with different attributes combination for clothers.
Example:
color - red blue green
size - XL X M S
pattern - checks lines
so output should be in below format in different combinations:
red - xL - checks
red - xL - lines
red - X - checks
red - x - lines
red - M - checks
:
:
green - S - checks
green - S - lines
Note:- In above example, no. of attributes is 3. but attributes can be N.
Below is the code, I have written. Hope it will be useful for anyone.
This is an non-recursive logic which will work for large value of N. time Complexity is O(n2).------------------------------------------------------------------------------------- package com.test; import java.util.Scanner; public class Solution { public static void main(String args[] ) throws Exception { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ Scanner in = new Scanner(System.in); int n = in.nextInt(); in.nextLine(); //to read new line String[][] attributes = new String[n][]; int i=0; while(i < n) { String temp = in.nextLine(); String[] values = temp.split(" "); attributes[i] = values; i++; } printAttributesCombination(attributes); } static void printAttributesCombination(String[][] attributes) { int count[] = new int[attributes.length]; int totalcount[] = new int[attributes.length]; //initialize the totalcount and temp index count initialize(count, totalcount, attributes); while(isDone(count,totalcount)) { printArray(attributes,count); } } static void initialize(int count[], int totalcount[], String[][] attributes) { for(int i = 0; i < count.length; i++) { count[i] = 0; totalcount[i] = attributes[i].length - 1; } count[count.length-1] = -1; } static boolean isDone(int count[], int totalCount[]) { boolean prevIndexSet = true; boolean canTerminateLoop = false; int i = 0; for(i = count.length - 1; i >= 0 ; i--) { if(count[i] == totalCount[i]) { count[i] = 0; prevIndexSet = true; canTerminateLoop = true; } else { count[i] = count[i] + 1; prevIndexSet = false; canTerminateLoop = false; } if(!prevIndexSet) break; } if(canTerminateLoop && i == -1 ) return false; return true; } static void printArray(String[][] arr, int count[]) { System.out.println(); for(int i = 0; i < arr.length; i++) { System.out.print(" " + arr[i][count[i]]); } } } -------------------------------------------------------------------------------------
Output:
- Thirumaleshwar Kunamalla March 07, 2014 in United States
==============
Sample1:-
============
3
a b c
d e f
g h i
a d g
a d h
a d i
a e g
a e h
a e i
a f g
a f h
a f i
b d g
b d h
b d i
b e g
b e h
b e i
b f g
b f h
b f i
c d g
c d h
c d i
c e g
c e h
c e i
c f g
c f h
c f i
Sample2:-
============
4
a b
a b c
d e
f i
a a d f
a a d i
a a e f
a a e i
a b d f
a b d i
a b e f
a b e i
a c d f
a c d i
a c e f
a c e i
b a d f
b a d i
b a e f
b a e i
b b d f
b b d i
b b e f
b b e i
b c d f
b c d i
b c e f
b c e i| Report Duplicate | Flag | PURGE
Amazon SDE-2 - 1of 1 vote
AnswersIn a book with N pages, pages are numbered from 1 to N. Find out how many times
- samar.pratap.singh.bundela February 06, 2014 in India for payments
each digit occurs in that book.
You are expected to complete the function getDigitslnBook, which takes an integer as input and
prints how many times each digits occur, one in a line.
The Nth line in the output denotes how many times the integer N-1 occurs in page numbers.
Constrains:
N will be between 1 and 1,000,000,000, inclusive.
The output will fit in an integer.
Sample lnputOO:
7
Sample Outputo : 0
1
0
0
Explanation :
The page numbers are 1,2, 3,4, 5, 6 and 7.
Sample lnput01: 11
Sample Output01:
1
4
Explanation:
Digit 1occurs 4 times, at 1,10 and 11.Rest of the digits occurs only once.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Math & Computation - 1of 1 vote
AnswersThere is a king, who has got 1000 bottles of Rum with him, of which One bottle contains poison. And he has any number of slaves. He has got 1 hour to decide which bottle contains Poison, and any slave who even takes a sip of the poison, dies within an hour. How many least number of slaves does the king need to use, to make out which bottle contains poison.
- pal January 22, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Problem Solving - 1of 1 vote
AnswersReverse words in a sentence.
- ami April 09, 2013 in United States
Ex:
Input: "reverse the word"
Output: "word the reverse"| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 1of 1 vote
Answersfind maximum number in an Array of elements
- Anonymus February 20, 2010| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays - 1of 1 vote
AnswersGiven an unsorted array A of size N of non-negative integers, find a continuous sub-array which adds to a given number S.
- Nits January 30, 2020 in United States| Report Duplicate | Flag | PURGE
Amazon Dev Lead - 1of 1 vote
AnswersFind the indices of all anagrams of a given word in a another word.
- aonecoding4 February 19, 2019 in United States
For example: Find the indices of all the anagrams of AB in ABCDBACDAB (Answer: 0, 4, 8)| Report Duplicate | Flag | PURGE
Amazon Software Engineer - 1of 1 vote
AnswersWrite a program to reveres string from intervals
- kumarami663 February 05, 2017 in India| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Coding - 1of 1 vote
AnswersGiven two strings needle and haywards that contains ASCII characters,write an algorithm to output a list of 0-based indices of the occurances of all anagrams of needle in haystacks
- Learner_Ash January 12, 2017 in United States| Report Duplicate | Flag | PURGE
Amazon Web Developer Algorithm