Hi, I just read your speed comparision of [perl vs C++]. Have you tried using a hash map? It's a bit unfair to compare different langauges with respect to hashing vs a sorted map, because the sorted map is asympotically slower.
Regarding that problem, if you hash the strings yourself, you can hash each substring in O(1) time. For example, when hashing the substrings of "abcde". Let's say you have hashed "abc", then to hash "abcd", you have stored hash("abc") which you combine with "d" in some reasonably smart fashion to compute hash("abcd"), which should give you a solution that runs in time.
Don't feel bad about not getting through the art of computer programming, I can't either :(. --Rrenaud 15:59, 4 Feb 2006 (EST)
Why do you feel so bad about not getting through the art of computer programming? I have not read that book before, but that does not mean I don't know the basic algorithms. Try solving more programming questions, I think it will help alot. How old are you? --Roticv 22:02, 25 Mar 2006 (EST)
I see I see. I will be 19 come this dec. Great keep up the good work. --Roticv 02:10, 26 Mar 2006 (EST)