Open CodeTestSEW opened 7 years ago
Hi SEW Team,
Clearly catbatrat is the longest word here but to the code that way I have, it finds cat, then doesn't find batrat so this word is eliminated. If I had the word bat in the list, then it will find cat, then bat, then rat and conclude this is a combination word.
When I do the reverse on such words, it get rat, then catbat and concludes this is a combination of catbat+rat.
But if the provided list has all combinations then I can eliminate the reverse match like you suggested. That will certainly speed up the process.
I am not clear on what condition the file should be sorted on but it appears to be sorted already.
I can definitely improve a couple of things and check the runtime.
Hi Ravi,
It means you need to improve your logic to handle such condition where there is a combination of more than two words.
Think about what other type of sorting could be applied to find longest word.
Sure, please provide with your updated solution.
Thanks, SEW Team.
Improved the performance. It now takes about 2 seconds. My result electroencephalographically is the longest possible combination word electroencephalographic+ally (27 chars) This is longer than phosphatidylethanolamine (25 chars) which I get if I run forward only.
Hi Ravi,
Good attempt but your answers are not correct.
1) Reversal of words is not required as you are trying to find words made of other words using the given word-list. 2) Sorting the word-list using a primary condition mentioned in problem statement might help you to get the 1st and 2nd largest words. 3) How will you write an efficient program to address the repetitive activity? Think about it.
Final output is expected in less than 30 seconds. Please look into the problem statement one more time and get back with your solution by 09/13/2017 12 pm PST.
Thanks, SEW Team