|We don't bite newbies here... much|
Re: searching problem (reverse substrings)by LanX (Monsignor)
|on Jan 18, 2013 at 10:33 UTC||Need Help??|
You mean matching only from the start?
Your sorting technique sounds clever, but the sorting itself isn't constant, I suppose something like O(n*log(n)).
IMHO the fastest solution should be a trie, if it's worth the overhead depends on the number of words to search.
Another simpler approach is abusing the regex engine, because from 5.10 on it has internal trie optimization and is f*ckingly fast!
thats untested pseudo-code I hope you get the idea! =)