Ad
  • Default User Avatar

    Thank you for all the feedback! I'm glad you liked my solution.

    I believe your estimate of n^2 log n is correct. In the end we have 3 * n lists (rows, columns, and blocks) of n sorted values. As you mentioned, the sorting of each list costs n log n. The runtime is then 3n * n log n => n^2 log n.

    This may not be, and probably isn't, the optimal runtime, but instead I was aiming for a solution that was easy to read and fairly concise.