A set of words is given, find out the longest chain of words in that, that can be made out of those words with the following rules:
- Each word in the chain is one letter longer than the previous word
- Each word in the chain differs from the previous word only by its last letter
Constraint Examples:
- ben -> bent-> bents is valid (meets all constraints)
- den -> dew is not valid (same length)
- den -> cent is not valid (differs by 1’st char [‘d’ != ‘c’])
I/O Example:
- Input: {ben, bent, dew, dents, dent, bet, den}. {ben, den, dew, dent, dents, ...}
- Result: 3 ({den, dent, dents}).
({ben, bent}) <-not longest