Round 1: (Online in Hackerrank)
- Print all possible words from phone digits
- Given a matrix where elements are inserted as 1 to n in row 0, n+1 to 2n in row 1 and so on till n^2 and you traverse the matrix in spiral manner find the kth number you will visit.
eg. n = 3
matrix: 1 2 3
4 5 6
7 8 9k = 4, output: 6
k = 6, output: 8
Round 2: (F2F)
- . Sort an array of 0’s,1’s and 2’s.
- Given a linked list like 10->8->3->4->5->6modify it to4->2->-1->4->5->6
The last number is subtracted from first number, 2nd last from 2nd number and so on till middle of link list.
First gave him a brute force approach O(N^2) , then O(N) approach in which reverse of 2nd half of list is done. He told to do this without reversing the list.
Then used a stack and gave him final solution.
Round 3 : (F2F)
- Given a number n and a pattern that follows like:(1 to 26): a,b,c,….z(27 to 52): aa,ab,ac,…az(52 to 78): ba,bb,bc,…bz…za,zb,zc,…zzaaa,aab,aac,…aazaba,abb,abc,……find the nth pattern
- Convert a Binary Tree to Doubly Link List in place
- Clone a graph and analyze the time and space complexity. First did it using two traversals of BFS and using map. Then did it using one traversal of BFS and map.
- Count the number of inversions in an array
- Tell a data structure which you will use to implement best fit algorithm. I told him BST. Then he asked me to implement it.
- Longest Common Subsequence (Both recursive and dp approach)
- Box stacking Problem
- One DBMS query select 2nd max salary from table,
- OS questions from deadlock, synchronization, scheduling, diff between process and thread.
Round 4:(Telephonic round)
- About my summer internship
- OS, DBMS , OOPS questions \
- Row with max 1s
- What happens when you type URL in browser and hit enter? Explain in detail.
- Given a number in form of array and number K you have to form largest number after swapping elements K times.
You can swap only adjacent elements
e.g Array -> 4 5 7 8 2 3
Output -> 7 4 5 8 2 3
Only algo was needed.
Thanks GeeksforGeeks. Placed@Amazon
Recruiter at amazon are very friendly. For each question working code was expected and time and space complexity was asked.
Interact with the interviewer if you get stuck. Try to come up to different approach to solve the same problem. Their main focus remains on how you see a problem and try to solve the problem. Dont jump to code it as soon as you are given the problem, first discuss it then go for coding if asked.
Be confident and do not give up if you cant get the perfect solution!!
If you like GeeksforGeeks and would like to contribute, you can also write an article and mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above