Longest word in dictionary | Interview Question
Anonymous User
225

I was asked this question in one of the interview recently I couldn't find this on leetcode.

Given a dictionary of words, ["n", "in", "tin", "ting", "sting", "string", "world", "orld", "old", "ol", "o"],
find the max. length of a word such that its sub words by deleting any one character is also part of dictionary.

Here , "string" -> "sting" -> "ting" -> "tin" -> "in" -> "n" is of length 6.
Similarly, "world" is of length 5 whose subwords are present.

Can anyone please suggest how to approach this kind of problem.

TIA

Comments (1)