Ad
  • Custom User Avatar

    The number of results for n is ( on the order of ) n^2 - in that sense, you're just not going to find an O(n) solution.

    In terms of requested number of results, it can be done in O(n). You can't be calculating n over k for every result to do that, but following the description works.

    If iterating over n items in O(1) time were possible, solving P problems would be a lot faster.

  • Default User Avatar

    I'm curious too.

  • Default User Avatar

    @Chrono79 .sort Is not stable in Node v8 and v10, but it's stable in Node 12 and up. Now it's a kata problem for not enabling Node v12.

  • Custom User Avatar

    arr.length is a property of Array.prototype and the kata prohibited Array.prototype methods. And I agree with you, so many solutions are using temp array, the worse is that they are marked as clever...

  • Default User Avatar

    I have solved it and got all testcases passed but not satisfied, in the sense that can it be done in linear time ?, like using two loops leads to O(n ^ 2). Can anyone please suggest the way or algorithm.

  • Default User Avatar

    In solutions people use arr.length(which is part of Array.prototype) and also in description it was nowhere mentioned about replace is prohibited. Also clearly mentioned no temp array but in many solutions I can see temproary array being created. It seems kata is not properly described.

  • Default User Avatar

    NO proper description, no test cases waste of time.

  • Custom User Avatar

    Please check if you can find anything helpful in this FAQ and if you tried everything and still no success, please share your code with us so we could take a look (remember about markdown formatting and spoiler flag). It is possible that there is some issue in the kata, but since you are the first one to report such problem, I somehow do not think it's really the case here.

  • Default User Avatar

    I have used sort but took care of it during number comparision, and when I take the same random test and try it out in codepen I am able to get the expected result, 10 test cases are failing on clicking attempt. And whats more weird is when i try to use console.log() for input I am seeing 13 test cases failing. Very weird behaviour.

  • Custom User Avatar

    There is no issue with the kata, if you're using sort, it's not stable in javascript and that could be your problem.

  • Default User Avatar

    I think there is an issue in the kata, like I am checking with my editor for even random tests its working but here it's not working. Could please help me out raising the issue.

  • Default User Avatar

    Once I decoded the logic I felt it bit simple, but yes to get through right logic was the tough part. It was a nice kata.

  • Default User Avatar
  • Default User Avatar

    Thankyou for providing a brief explaination regarding the Regexp. Very informative content.

  • Custom User Avatar
  • Loading more items...