Better way to do this dict comprehesion

Sayth Renshaw flebber.crue at gmail.com
Wed Mar 8 00:02:24 EST 2017


> > But the given problem states there will always only be one number appearing an odd number of times given that is there a neater way to get the answer?
> 
> Take a step back for a moment. Are you trying to find something that
> appears an odd number of times, or a number of times that counts by
> three? First figure that out, THEN see if there's a better way to do
> what you're doing.

A number that appears an odd number of times.

> 
> To find an unpaired number in linear time with minimal space, try
> stepping through the list and either adding to a set or removing from
> it. At the end, your set should contain exactly one element. I'll let
> you write the actual code :)
> 
> ChrisA

ChrisA the way it sounds through the list is like filter with map and a lambda. http://www.python-course.eu/lambda.php Haven't had a good go yet... will see how it goes.

Thanks

Sayth



More information about the Python-list mailing list