Apple Interview Question

Print out, from small to big, of a sequence intergers, without sorting.

Interview Answers

Anonymous

Sep 22, 2013

If the integers are within a small range, then create an vector array, loop through all integers and flag the array. Then print out.

1

Anonymous

Dec 6, 2015

Construct binary search tree and do inorder traversal.

1

Anonymous

Feb 18, 2019

Use a visited array. Run n passes on the given array picking smallest integer every time that has not been visited yet

Anonymous

Oct 11, 2012

priority queue then

4

Anonymous

Apr 8, 2013

The problem refers to dynamic programming, Longest increasing sequence in the given array. The time complexity of solution is o(n2).

2

Anonymous

Sep 13, 2013

Add the sequence of integers to HashSet, which will apply natural order and then print the collection elements.

3