Recently Amazon visited our college and details are as follows.
There were two questions.
1. N strings are given.Convert all string to corresponding decimal value typed in an Alphanumeric Keypad (e.g. “bdg” -> 234). Then print all strings in decreasing order of their decimal value. If they have same decimal value then print lexicographically smaller first.
5 Amazon sun run Output: 262966 amazon 786 run 786 sun
2. Write a code to print all possible combinations(order matters) of characters of string in lexicographical order.
Output: A, AB, ABC, AC, ACB, B, BA, BAC, BC, BCA, C, CA, CAB, CB, CBA
Round 1: 45 minutes
This started with a brief discussion on project. She quickly moved on to Coding questions.
She made me write an error free code for “Count all pairs which sum to k in a BST”. Also she added that duplicates may be present but on left side only.
First she discussed for approach and then constrained the space complexity to be O(1). She checked the code rigorously.
Then there were 3-4 coding questions. She just discussed approach.
–Update all nodes in a bst to be sum of all elements greater than or equal to it.
– Stock problem/ Given an array ‘arr’ find maximum difference between two elements (max(arr[i]-arr[j]) where i>=j).
-Then there was this awesome question… Given a perfect binary tree.
print nodes in a specific manner. e.g-
15 / \ 13 14 / \ / \ 9 10 11 12 / \ / \ / \ / \ 1 2 3 4 5 6 7 8 print - 1 8 2 7 3 6 4 5 9 12 10 11 13 14 15
I told her approaches having some space complexity. Again she restricted space complexity, and I got an efficient solution by recognizing some pattern 😉 .
Round 2: 25 minutes
There were just two questions.
1- Given a string having no spaces, and a dictionary.Problem was to find if that string can be splitted in multiple strings such that all the splittedstrings are in dictionary. I was provided a function search(string str) which will tell if a particular string str is in the dictionary or not.
I quickly gave a recursive approach.
2- The second question was well known vertical order traversal of a binary tree. She just discussed how to implement various approaches in C++.
Then there was discussion on types of projects assigned to Interns and blah blah.
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.
- MathWorks Interview Experience (EDG, Oncampus)
- ServiceNow Interview Experience Oncampus
- UHG Interview Experience | OnCampus- 2019
- InfoEdge Interview Experience | OnCampus-2019
- Amazon Interview | Set 54 (For Internship)
- Amazon Interview | Set 52 (For Internship)
- Amazon Interview | Set 45 (For Internship)
- Amazon Interview | Set 60 (For Internship)
- Amazon Interview | Set 61 (For Internship)
- Amazon Interview | Set 44 (For Internship)
- Amazon Interview Experience | Set 265 (For Internship)
- Amazon Interview | Set 96 (On-Campus for Internship)
- Amazon Interview Experience | Set 408 (Internship)
- Amazon Interview Experience | Set 407 (Internship)
- Amazon Interview | Set 46 (On-campus for Internship)