Ad
  • Custom User Avatar

    You forgot the 0

  • Custom User Avatar
  • Default User Avatar

    Big O Notation on a 6kyu kata ? :(

  • Custom User Avatar

    because this is O(n²). You need an O(n) algo.

  • Custom User Avatar

    Thanks. I didn't pick that up from the introduction text. Perhaps it should be more promenant, and maybe a unit test for performance. I've refactored my answer successfully.

  • Default User Avatar

    Tag added.

  • Default User Avatar

    Sorry for the Spoiler tag its my first time here hehe

    Ok i will try changing that thanks!

  • Custom User Avatar

    Yes, mark your post as having spoiler content next time.

    About your code, it seems unshift is expensive in computing time, try doing it in another way.

  • Default User Avatar

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

  • Custom User Avatar

    Add performance tag to the kata. Maybe clarify what "Some lists can be long." means ;)

  • Custom User Avatar

    yes, you need something more efficient (inputs are huge, in the full test suite)

  • Custom User Avatar

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

  • Custom User Avatar

    @chrono79 - thanks for all the feedback very appreciative

  • Custom User Avatar

    When I told you about overwritting the var you use in the loop, I meant the i var, normally you change its value in the last expression, see it here. While what you've done somehow works, it's not the normal way of doing it, and it seems confusing, you could use a better suited loop for that like while (note that it'll be still a nested loop and it won't work in this kata either).
    About mutating the input, yes, I was talking about arr, note that your code could be only a function amongst another functions and you're destroying the array, in functional programming that's very bad, and here in CW you'll find some katas where doing that changes the value of the expected results.

    About performance, well, I'm not so well versed about it to refer you to some source, try googling Big O notation.

  • Custom User Avatar

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

  • Loading more items...