Interview Question

Software Developer Intern Interview London, England (UK)

The question was to fin the number of time an array was

  schifted. For example: [1 2 3 4 5 ] is 0 because it is in order [7 5 6] is 1 because it should be [5 6 7] [7 8 9 2] is 1 too.

Interview Answer

1 Answer


The question is just how to find the minimum in an array which is nearly sorted.
Of course, crossing lineary the array is not the good solution. You need to do a divide and conquer algorithm.
After that, the solution is min(index_of_min, length - index_of_min + 1)

Interview Candidate on Apr 22, 2013

Add Answers or Comments

To comment on this Question, Sign In with Facebook or Sign Up