Amazon Interview Report
- 1of 0 votes
AnswersThis site had been useful for my preparation. So, I wanted to post the questions that i faced today in Amazon phone interview. I'm listing the questions..
- Metallicatony September 10, 2008
1) Given two arrays, how will you find out the common elements in both?
My Ans: Take every element from Array1 and iterate it over Array2 to find any match. If matched then print it as a common element. Else go for the second element in Array1 and so on until the end.
2) What is the complexity of the above algorithm?
My Ans: O(m x n) which is equivalent to O(n power 2) if m = n
3) Think of an efficient algorithm for the same problem (He gave me some time and wanted me to mail the code in any language)
My Ans: Create a map with the given Array1. Every element in Array1 will be a key in the map. And the values for the keys contain the number 1 (counter). Iterate Array2 and compare with the keys of map. If present, then increment the corresponding key's value.
Common elements are those that have their key's value > 1. (I assumed that the element occurs only once per array. No repetitions in one array).
4) What is the complexity of the above algorithm?
My Ans: O (n) - because we are iterating only one array| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersHe explained about a webserver and its logging technique in a log file.. then was asked a question related to regular expression to match a 9 digit number in the log file..
- Metallicatony September 10, 2008
My Ans: [0-9]+ in perl| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 1of 0 votes
AnswersOOP Concept - He wanted me to design a player playing a card game.
- Metallicatony September 10, 2008
My Ans: I explained how a card class can be created with its properties like - Value of a card, Sign of card
Then i explained a class for a player.
He asked - how i will represent a player holding a set of cards.
My Ans: I told that player is a different class and card is a different type of class as explained. And a card's properties can be inherited to a player's class and can be used to represent "a player holding a set of cards.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Object Oriented Design