Amazon Interview Experience | Set 152

Amazon written round – Time 1 hour.
1. Given an array of 0s and 1s, find the position of 0 to be replaced with 1 to get longest continuous sequence of 1s.

Eg: Array- 1,1,0,0,1,0,1,1,1,0,1,1,1
Output - index 9
Assuming array index starts from 0. 

2. Given an unsorted array, find the k smallest elements

Array {9, 5, 1, 4, 13, 6}
k = 3
Output: 1, 4, 5 

3. Find the minimum distance between any 2 given nodes in a tree.
Sample_tree
Minimum distance between 2 and 11 is 3
2–>5–>6–>11

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 :


Be the First to upvote.


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