Uber Interview Data Structures and Algorithm
Anonymous User
1703

Question 1: You are given an array with numbers, each round, half of the elements are deleted, the lower number stays, the higher number goes. Comparison is only among consecutive elements.

Example1:
1,2,3,4,5,6,7,8
Round1: 1,2,3,4,5,6,7,8
Round2: 1,3,5,7
Round3: 1,5
Round4: 1
1 is winnner

Example2:
1,2,3,4,5,6,7
1,3,5,7
1,5
1
1 is winner
Note: if number is odd, last element just moves to the next round
Print these rounds.

Question 2: Now you have this algorithm. Generate the configuration of the original array s.t. lower elements are eliminated later.
Example1:
Given, n = 7
generated answer:
1,7,3,5,2,6,4

Example 2:
n = 8
1,7,3,5,2,6,4,8

Example 3:
n = 9
1,9,5,8,3,7,4,6,2

Comments (5)