Algorithm help per favore
wrbt at email.com
Wed Jun 18 17:46:05 CEST 2003
I need to take a list (probably 20k to 40k elements) of numbers and
remove consecutive duplicates. Non consecutive duplicates are ok.
Example: [6,3,3,3,5,7,6,3,4,4,3] => [6,3,5,7,6,3,4,3]
The 3 and 6 can appear more than once in the result set because
they're separated by another value. Obviously this is trivial to
accomplish by walking thru the list and building a new one (or yanking
elements out of the existing one) but I'm curious if anyone knows of a
more clever way, with speed being a goal more than memory usage.
More information about the Python-list