Amazon Interview | Set 120 (On-Campus for Internship)

Recently Amazon visited our college and details are as follows.

Online Round:
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.
Input:

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.
Input: “ABC”
Output: A, AB, ABC, AC, ACB, B, BA, BAC, BC, BCA, C, CA, CAB, CB, CBA



Interview:
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 contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.


Write your Interview Experience or mail it to contribute@geeksforgeeks.org



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.