Amazon Interview Question: Given an large list of unsort... | Glassdoor

Interview Question

Software Engineer II Interview Bengaluru (India)

Given an large list of unsorted numbers, find the smallest

  number. You can access the list only 3 numbers at a time, and keep moving forward 1 number at a time.
Tags:
technical, data structures
Answer

Interview Answer

6 Answers

12

Otherwise called the sliding window problem

Interview Candidate on Jun 19, 2012
1

Use the selection sort and after the pass stop the iterating. Time complexity will be O(N) & only one swap.

Vasant on Jul 14, 2012
0

Use the selection sort and after the first pass stop the iterating. Time complexity will be O(N) & only one swap.

Vasant on Jul 14, 2012
1

Did they asked to write the code of the solution? or just pseudo code.And did they added any constraints? Otherwise this is pretty straight forward problem using Insertion sort.

Rishi on Sep 20, 2012
1

You can access the list only 3 numbers at a time: It tells we can read three numbers one after other in N/3 Iterations. So Time complexity will be O(N/3)

Anonymous on Jun 23, 2015
0

This is sliding window problem and priority queue DS can be used to solve this.

Harsha Jayaramachar on Nov 6, 2015

Add Answers or Comments

To comment on this, Sign In or Sign Up.