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.
That feeling when you created a dictionary, and then two more cycle, and the guys did everything in one line =)
a bit overcomplicated. In general you can put in return only a boolean expression.
О(n)+O(1-2)?
it really should have a failing test on memory allocation with some IEnumberable the generates billions of values.
@Pankwood, @thanhdoan
Problem here is not a O()
Problem here is an IEnumerable in C#.
Possible, it can be infinite.
You can try it with simple method: https://gist.github.com/IDontKnower/5df0a1a5d957ec37f719674eafeeacf4
I think, in my example it's realy hard to get GroupBy or Sort)
More code BUT definitely more optimal than 99% of the solutions here. Optimal is the way !!
Nice simple 1 liner BUT certainly not optimal.
Most solutions here parse through the entire collection and are far from optimal. What if the collection contained a file with 10 trillion numbers and the offending number was 4th on the list or worse 1st on the list. Why parse a collection that big only to discover the offending number was 1st on the list ?
Rather a few more lines of code.
This solution clearly should not be the best since it has unreasonably high memory usage and footprint.
Good for a one liner, but far from fast.
@Pankwood, I think you should not need to use orderBy as it will take you O(nlogn) time so it is not better. Correct me if I am wrong.
I am not sure 100% about GroupBy's bigo but I think it will take you O(n) for group therefore in general it will take you O(n). I have similiar implementation by using hashtable, but IMHO it is the best answer ans he understands very well about Linq and utilize it very well. I really like it.