Ad
  • Custom User Avatar

    it's because first group matching white spaces as well.

  • Custom User Avatar
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    The math skills were not the point of this kata. This kata does not have arithmetic or any other math related tags attached it besides algorithms, because there is the possibility of a loop. Your reasons for why this kata should be 8kyu are faulty because no first year java course, let alone first course, should be looking at OOP. I find your comment negative and not constructive towards a well implemented kata. Please, in the future, provide positive or constructive feedback based on the parameters of the kata and pursue kata that you would personally enjoy.

  • Custom User Avatar

    The math skills required to solve this are trivial, and possibly one of the first things taught in a student's first java class.

    This should certainly be an 8kyu

  • Default User Avatar

    That makes pop an O(n) algorithm and push an O(1) algorithm.

    Using sort makes pop an O(1) algorithm and push... well since it's inserting a single out-of-place element into a pre-sorted list, with a good sorting algorithm the efficiency should be O(log n). (You could get O(log n) efficiency by performing a binary search to find where to insert the item and then inserting it there, but it's easier to offload it to the built-in sort function and trust that it works efficiently for pre-sorted lists.)

    So you're trading off one O(1) for another O(1) (no improvement) and a O(log n) for an O(n) (you made it worse).

  • Custom User Avatar

    You would think that JS supported Object.values but it doesn't :(