Amazon | Tech Screen | Max Swap Count
Anonymous User
737

Asked 4 questions in the tech screen, though I couldn't make it past the first due to algorithm efficiency. Initially I thought it was because of the language I was using (Ruby) so I re-wrote the solution in Python. That being said it still timed out so I started implementing a merge sort and keeping track of the swaps in a counter. Unfortunately I ran out of time on that one.

Problem is:

  • Given an algorithm which sorts an array of size n by finding all pairs (array[i], array[j]) such that array[i] < array[j] and swapping said pairs, find the amount of swaps needed to successfully perform the sort.
Comments (0)