Ad
  • Default User Avatar
  • Default User Avatar

    it won't give an extra column? if not it's quite cool

  • 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.

  • Default User Avatar

    I love how you created the blocks and used array's 'every' method. I troubled over traversing blocks for a little bit and love how you were able to organize them. Moreover, I didn't know about array's every method. Thanks for positing.

    By chance do you know the time complexity of your solution ? just trying to understand time complexity more. It does doesn't matter since the input will never be massive, but am interested for learning. initially my thought is that organizing the data takes n^2 (n rows with n items). js' sorting algoritm takes n log n, I believe. it's done three times for n array. n^2 + (n log n * 3n) => n^2 log n ?

    any feedback appreciated!