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.
i think code is bad for large arrays, am i wrong?
enumerate creates a pair index, value for each element in the list/array passed in. That's how he's incrementing p, by adding the index to it each time rather than actually incrementing it by 1 in each iteration. I honestly wished I would have thought of this.
This comment is hidden because it contains spoiler information about the solution
this could require a lot of space with larger arrays. What if the outlier is the last number in a very large array? You'd have to append the entire array. What if you just used a while loop that breaks after one list has more than one integer to determine if the array is even or odd and then iterated through the list to return the outlier.
Holy cow. I had no idea about this "and" behavior. Unlike some languages where logical operators always return True or False, Python's "and" returns the last evaluated operand!
This doesn't even work for large odd lists...
ok now i can sleep peacefully thankyou
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
While the code is short, it runs through the entire list twice! :Urgh:
It is neither clever nor a best practice.
very inefficient
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
What should I be surprised about? In this solution, we iterate the entire list twice, while on average we only need to check half of the list to find an outlier. We should consider general complexity, not the special case when the list has 3 elements.
Loading more items...