On Tue, Dec 30, 2008 at 7:10 PM, Roel Schroeven <rschroev_nospam...@fastmail.fm> wrote: > Hm, you just changed an O(n) algorithm to an O(n**2) algorithm. No big > deal for short strings, but try your solution on a string with length > 10000 and see the difference. On my computer the O(n) version takes > 0.008 seconds, while your version takes 8.6 seconds. That's 1000 times > slower.
Yes you are right :) Sadly :/ I wonder if there is a way to implement the same thing with close to O(n) complexity using list/dict comprehensions. cheers James -- http://mail.python.org/mailman/listinfo/python-list