Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
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 = []
Search for a famous algorithm to detect cycles ...
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.