set
(wordsPresent
) and add all the words in the list to the set.memo
) to store the length of the longest word chain for each word.currentWord
is in the memo
, return its value.maxLength
to 1.currentWord
, creating newWord
by removing one character at a time.newWord
is in wordsPresent
, perform DFS on newWord
and update maxLength
.maxLength
in memo
for currentWord
.maxLength
.