# Amazon Interview Experience | Set 346 (For SDE-1)

**1st Round :**

- Check if tree is a binary tree or binary search tree or not.
- Write a program to output power(m,n).
- Given an infinitely long sorted array having -1’s at the end search a value in that array
- Provide the complexities for the above questions.

After 20 minutes 2 guys entered my cabin and straight forwardly they started technical stuff.They started with my projects,I told that I am working in support project

**2nd Round**

- Design a musical juke box with functions

1) add song

2) delete song

3) top 10 played song at any point of time

We had a lot of discussion about this around 40 minutes using different data structures like hashmap, heap. - Longest consecutive path in a binary tree.

I told my approach but they didn’t got that then I wrote recursive code and explained. - Find the sum of all left leaves in a binary tree.

Initially I told level order traversal approach.They asked me to code.They seems satisfied but again come up with a question to optimize the space.Told the approach using post order traversal

**3rd Round :**

This guy is very friendly.

- Merge two sorted linked list into one without any extra space.
- Given a binary tree along with a value. The question is to find the mirror of that node,the value always exist in the binary tree

- for this tree mirror of 2 is 4 and for 1 mirror is NULL.
- Given a array with n songs,we have to play all the songs only once.Given only 2 functions

1)playsong(songid)

2)getRandom(n) – return the random values in between 1 to n

Told hashmap approach he told if the getRandom() give the same values million of time then its sucks.So I modified my approach and he was impressed.

**4th Round :**

This round was with SDM of another team

- Segregate even and odd number in the list with out using extra space.
- A kind of design question. Given amazon log files of two days.He asked me to find the users who logged in both the days. Had discussion using Hashmap,he want to optimise further I gave solution using trie with little modification in its structure

struct Trie { int count[2], bool isleaf; Trie *child[26]; Trie() { count[0]=count[1]=0; isleaf = false; for(int i=0;i < 26;i++) child[i]=NULL; } };

- He appreciated me and left.

**5th Round (Bar Raiser)**

- Had discussion about my projects and its extensions.He gave some advise
- Serialize and deserialize a binary tree.

I told the approach using two traversals inorder and preorders.He asked me to code directly then I explained him but he didn’t got my approach and he continuously used to ask many questions .Finally I told using one preorder traversal with markers he told that he know that solution.

I would like to thank my friends and geeksforgeeks who are always with me helping all the time,

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.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above

## Please

Loginto comment...