Open In App

Amazon Interview Experience | Set 152

Last Updated : 27 Jun, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads