Ad
  • Custom User Avatar

    It seems like searching in list takes too long. Searching in unsorted list got O(n) complexity. And you are doing this search for every node, so there are n searches, which means that complexity of your solution is O(n^2). And I think they got test with the giant amount of nodes.

    Also, as already mentioned that here before, you are using mutable type as default parameter. In this main will be empty only for the very first test. In the second test main will be containing all the nodes that have been added there in the first test. In the third test main will be containing all the nodes that have been added in the first test and then in the second test, and so on. That means that in the last test main will be containing all the nodes from all previous tests, the search will be extremely low.

  • Custom User Avatar

    it's simpler than that, do some search and you'll find the idea to solve it.
    Also as a general tip, don't ever use mutable data types as default parameters. Instead do this:
    def foo(arg = None):
    if arg is None:
    arg = []

  • Custom User Avatar

    Search for a famous algorithm to detect cycles ...

  • Custom User Avatar

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

  • Custom User Avatar

    Evenness here simply means whether number is odd or even. For this kata, it means that either 1 number is even, and others are odd, or 1 number is odd, and others - even.

  • Custom User Avatar

    what is the definition of the evenness? Does it mean this array is linear?

  • Custom User Avatar

    Why this was spoilered?

  • Custom User Avatar

    Hello, please don't post solutions in kata's Discourse. There is a Solutions section for that matter, and even there, mark your post as having spoiler content when they do.

  • Custom User Avatar

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