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.
nice but using the count method inside a loop can be inefficient for large lists because count iterates through the list each time it is called, leading to an overall time complexity
also the method is straightforward and easy to implement but may not be optimal for very large datasets.
WOWWWWWWWWWW :{
Yes. The "else: pass" in your code can be omitted without any issues.
I'm not sure if I understood you correctly, but this is, in fact, O(n^2) too.
Just a question for onestringers: indeed if works without else?
Victor Granddadcoder
I spend 10 minutes thinking hard and bro just does it in three lines...
The question asks to return a new list, not modify the list in place, which you are doing here.
You are also repeatedly counting the number of items in order and modifying the list which is not required.
For the reverse, if the idea was to get a space efficient solution, is would be good, but in this case it's just extra complexity.
Sorry, but this solution is not efficient. This is an O(n^2) solution. As ans grows you're doing O(n) search on each iteration.
It already has been marked as spoiler.
Oh, sorry! I thought these comments were only visible to users that had completed the kata. I'm trying to flag the spoiler but it says I'm not authorized to do so. I can't find a way to delete the comment either now, maybe due to your reply
Please use the spoiler flag when posting potential spoilers. Your comment is visible to everyone from the dashboard, including users who haven't solved the kata.
This comment is hidden because it contains spoiler information about the solution
you and me with the for loop, while loop, count combo <3
ughhh i feel so primitive with my n**2 solution
I don't think using the count method for each element is very natural. It is pretty expensive
Loading more items...