Adobe Interview Question
Software Engineer / DevelopersYes, the answer in the book doesn't work if you have a compound word composed of 3+ shorter words
ie: [reallytallhat,really,tall,hat]
you need to push all the letters into a trie. if you found an 'end marker', then you might be at word boundary, keep adding to your trie, but also start a parallel 'tracker' pointer at the root.
repeat each time you hit a word boundary.
when you've reached the end of the word, if your tracker pointer is at a word boundary, you have a composite word. in this case make sure your list is sorted from shortest to longest before you start.
Yes, the answer in the book doesn't work if you have a compound word composed of 3+ shorter words
ie: [reallytallhat,really,tall,hat]
you need to push all the letters into a trie. if you found an 'end marker', then you might be at word boundary, keep adding to your trie, but also start a parallel 'tracker' pointer at the root.
repeat each time you hit a word boundary.
when you've reached the end of the word, if your tracker pointer is at a word boundary, you have a composite word. in this case make sure your list is sorted from shortest to longest before you start.
****************************8
- anonymous May 24, 2008