more solutions
I liked the trie =]