Amazon Interview Question

Given 'n' integers, print the numbers given in a range

Interview Answers

Anonymous

Mar 30, 2012

Use binary search tree to save the n numbers and print all the numbers that fall between the given range.

1

Anonymous

May 25, 2012

The question doesn't say the numbers are sorted, so it would be cheaper to do a linear search. If the numbers were sorted then do a binary search for either ends of the range and print the numbers in between.