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.
You must use a spoiler flag when you post code somewhere (I put the flag for you this time).
Each time you call the
count
method, it needs to parse the whole list to count the number of elements matching its argument. You do that for every element, that's an aweful thing in terms of efficiency. If your list has 10 elements, your code needs to perform 100 operations (10 * 10). If your list has 1000 elements, 1,000,000 (1000 * 1000). And so on. It's easy to understand that with a large list that becomes incredibely huge. That's why it is said to be inefficient. You need to find a better approach.if the list you were checking for was really big and had the unique element in the last, you would be iterating through all elements in the list to reach the answer. this is one way to write the function, but not a very efficient way, as it wastes a lot of time on unnecessary checks which can be cut down
Can you explain please, why is my solution consider "inefficient"?
Your solution is too inefficient. Not an issue.
This comment is hidden because it contains spoiler information about the solution
Your code produced the number
8.0
, but the correct number would have been7.0
.expected:<7.0> but was:<8.0>
what this mean?
What happens when the unique value is at the first position as the test says? Your code is returning the other value. You can print the input and debug your code easier.
This comment is hidden because it contains spoiler information about the solution