Related Articles

# Amazon Interview | Set 15

• Last Updated : 19 Aug, 2019

For the position SDE I.

I had an online test through interviewstreet and following were the questions:

F2F Interview :
1. Generate all valid permutations using ‘(‘ and ‘)’. Valid permutation is the general definition of valid sequence of the opening and closing brackets.

I told him a solution where we would generate a combination using a recursive solution and prune the cases where a valid combination is no longer possible. The solution was fine and not that difficult. But the interviewer was very interested in knowing if I can calculate the complexity of the solution. He gave me some hints but it was just not striking me. I told him my approximate answer. We moved on.

2. Create an ancestor matrix for a tree.

The solution would seem simple. But since the matrix is N*N, the interviewer wanted some tricks to reduce the complexity of the write operation on the matrix.

I told him a solution where you can initialize the matrix with all zeros and only write 1 for the ancestor cell using a modifies recursive solution and linkedlist.
He was fine with the solution

F2F 2:

1. Find the maximum weight node in a tree if each node is the sum of the weights all the nodes under it. Obviously tree nodes can have negative weights.

F2F 3:

```eg:
Tree is:
1
2    3
4   5 6   7
would become:
1
2-->3
4--->5--->6--->7```

F2F 4:
Detailed discussion on projects I did in college and about my interests.

This article is compiled by girlforce. 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.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon. GoogleE-Litmus and Microsoft Test Serieses.

My Personal Notes arrow_drop_up