Friday, March 29, 2013

How I made it to



Hi friends, I've recently joined Amazon. A lot of my friends keep asking me about what was asked in the interview. So I am  going to list as many questions that were asked as I can remember. Hope it helps.

First, there was an online coding test. The test had 3 questions and a time duration of 2 hrs. I managed to solve 2 of them correctly. 1 of them was to implement run length encoding, (aaaabbbcc = a4b3c2) can't remember the other two. Then started an array of interviews - 3 phone and 5 onsite in Bangalore. Here's the list of questions:

  1.  Given an integer n, print set of list of numbers that sum up to n. For example, if input is 4 then the output set should have {4}, {3,1}, {2,1,1}, {2,2} and {1,1,1,1}. Also {1.3} and {3,1} are the same.
  2. Given an array A, print an output array B such that B[i] = product of all elements of A except A[i] and you are not allowed to use a division operator. This question was asked twice, first on phone then in an onsite interview as well, where I told that this had already been asked.
  3. Given an n x n matrix, whose rows are sorted and columns are sorted. How will you go about searching an element in such a matrix.
  4. Find out if a linked list is palindrome or not. Eg. 1-->2-->--3-->2-->1 is palindrome.
  5. Given a binary tree. Each node, apart from having a left and right pointer, has a right-next pointer, which points to its right neighbor at the same level. Initially all right-next pointers are pointing to null. Write a program to populate all the right-next pointers.
  6. Given price of a company's stock for 'n' days. You can buy some stocks on a day and then sell them at any day later than the day you bought them. Find out the maximum profit that one can make.
  7. Print boundaries of a binary tree. Boundary of a tree is its left border + its leaves + its right border.
  8. Given a BST whose 2 nodes are swapped. Find out those nodes.
  9. Given an n x n matrix. From one block in matrix, you can either go right or go down. Some of the blocks in matrix have mud and they cannot be traversed. Write a program to find out the no. of ways of reaching right bottom from left top of the matrix.
  10. Suppose 'b', 'c', 'd' are all synonyms of 'a'. What data structure will you use to represent this relationship.
  11. Implement your own hash-map.
  12. Given a linked list, find if there is a loop. If its there, find the node where loop starts.
  13. You have to search a word in a very large stream of words. How will you do it?
  14. Some questions related to hashing. Write an efficient hash function.
  15.  What are different ways of inter process communication? When will you use which one?
  16. Difference between TCP and UDP. When will you use which one?
  17. You are given a dictionary of valid words. Given a word, find all the anagrams which are valid words. A word is valid if it is present in dictionary. You are free to implement dictionary the way you want.
  18. A lot of questions on project mentioned in resume.
  19. Difference between thread and process. When will you use which one?
  20. What is REST, and some basic questions? [This was because I mentioned that I have written RestFul services]
  21. Why should we use web service instead of providing jars of our functionality.
  22. What happens when you type www.amazon.com in browser and hit enter.
  23. 2 linked lists merge into each other. Find the merging point.
  24. Some people visited amazon's website on Saturday. Some visited it on Sunday. Find those who visited on both days.
  25. Draw class and sequence diagrams for an online movie ticket booking system.
  26. Some behavioral questions, very few though.
That's it guys. For those who want to join the likes of Amazon, just a small piece of advice- your approach and way of thinking matter more than whether you were able to correctly solve the problem. Of course, you should be able to code whatever approach you decide to take.