I am working on simple problem of constructing sentence out of line with no space and punctuations. So it needs dictionary to find if such word exist. For eg. Below is sample of how i created trie in python using dict.
Trie = {o: {on: {one: ""}}}
Now question i have is, "on" and "one" both are valid words, in above problem i would always choose longest matching hence "on" word will not be considered but if i want to write such code how do i do that? Like if value of key is not another dict then its a word But for "on" key would be another dict containing longer word here its "one". I can not have "on" pointing to "' and at the same time to another dict!
Something is wrong somewhere, maybe there is another algo which is for this problem. Link to resource is fine with me