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
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.
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
https://en.wikipedia.org/wiki/Big_O_notation
I keep seeing people talking about o(n^2). What does this mean?
I'm glad to see a normal answer at the top now!
Thank you..I thought as much
Hmmm....Splendid, but i have a question What will be the time complexity if it grows of each number?
Because using a count method inside a loop is supposedly a O(n^2) I think correct me if I'm wrong
Loading more items...