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.
oh yeah i ha trouble understanding too thanks
Hello,
You're right about set.pop() removing and returning a random element. The missing link here is that when you get to the return statement, the set only ever contains one value because of the problem specifications.
In the for loop, whether an element ultimately ends in or out of the set is determined by the parity (even or odd) of the number of times it appears: the first time it appears, it's added to the set for the first time, then the next time it's removed from the set, then the next time it's added again, and so on.
In the end, only elements which appear an odd number of times end up in the set, and according to the problem, there's only one such element in the sequence, so it is the only one that could possibly be returned. So essentially, it is choosing randomly, but it only ever has one option.
Hope this helps!
Hi,
I was fiddling around with this little bit and I have noticed that "nums.pop()" gives the "nums[0]" value.
For example, when there was more than one values of "nums", nums.pop() will always spit out the first number in the list.
I thought set.pop() picks randomly.
Is there something that I am missing?
Can someone please explain why its not picking out randomely?
Thank you.