Bloomberg interview question

Rotate array by n elements. Sort names based on last name.

Interview Answers

Anonymous

Jan 20, 2015

Rotating the array by N elements - there is a nice trick to do this in place: - invert the entire array - invert first N items (or last, depending if rotating right or left) - invert rest of the array I found this trick initially to rotate strings, but can be used for arrays as well.

3

Anonymous

Mar 15, 2015

What would be the time complexity? O(n)??