思考题 that seems easy
A perfect word
Given N strings. Find out a longest string so that each substring of it is one of the N strings.
Orange boy solved the problem after 1 min
Solution By XGN
Sort the strings by increasing length. A string is OK to be the answer if its length is 1 or all the substring of its length-1 is OK. Then at last find out the answer.
at -'a' is OK and 't' is OK, so OK
ata -'at' is OK and 'ta' is OK, so OK
atat ->'ata' is OK but 'tat' is not, so no ok