Ad
  • Custom User Avatar

    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.

  • Custom User Avatar

    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

  • Default User Avatar

    Can you explain please, why is my solution consider "inefficient"?

  • Custom User Avatar

    Your solution is too inefficient. Not an issue.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Your code produced the number 8.0, but the correct number would have been 7.0.

  • Default User Avatar

    expected:<7.0> but was:<8.0>
    what this mean?

  • Custom User Avatar

    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.

  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution