There were 2 questions to be solved in 105 minutes
question 1: You are doing performance test for a sorting function at Amazon. Sorting function is defined to be selection sort(in some fancy words). Find out number of swaps needed to sort the array.
eg: given array [1,3,4,5,2], sorting happens like [1,3,4,2,5] =>[1,3,2,4,5] => [1,2,3,4,5]
question2:
consider goods to be * and compartment boundary to be |. Find out number of good in closed compartment.
given string = "|**|***|"
find out goods for these inbetween these positions [(1,6)(1,8)]
result should be [2, 5], as there are 2 * (closed) in between 1 and 6 positions and 5 * between 1 and 8 positions