-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCombinedWordsDescription.txt
More file actions
32 lines (24 loc) · 952 Bytes
/
Copy pathCombinedWordsDescription.txt
File metadata and controls
32 lines (24 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
======================
Programming Problem - Find Longest Word Made of Other Words
======================
Write a program that reads a file containing a sorted list of words (one
word per line, no spaces, all lower case), then identifies the longest
word in the file that can be constructed by concatenating copies of
shorter words also found in the file.
For example, if the file contained:
cat
cats
catsdogcats
catxdogcatsrat
dog
dogcatsdog
hippopotamuses
rat
ratcatdogcat
The answer would be 'ratcatdogcat' - at 12 letters, it is the longest
word made up of other words in the list. The program should then
go on to report how many of the words in the list can be constructed
of other words in the list.
Performance matters: the program should return results
quickly even for very large lists (100,000+ items).
Please find attached a file with 173k rows, for testing purposes.