Jun-15-2019, 07:20 AM
But creating a copy of the list makes the runtime even worse.
In addition to what i said above not only numbers.count()
has to iterate over the whole list, so has numbers.remove()
as this method has to search for the element to be removed.
If n == len(numbers) worst runtime is O(n) + O(n)*2*O(n)
If n is big you really don“t want this to be.
In addition to what i said above not only numbers.count()
has to iterate over the whole list, so has numbers.remove()
as this method has to search for the element to be removed.
If n == len(numbers) worst runtime is O(n) + O(n)*2*O(n)
If n is big you really don“t want this to be.