No Prefix Set

  • + 0 comments

    Same thing happened to me. My solution was only checking if the current word contained the ending of a previous word in the list (meaning the current word has a previous word as a prefix).

    The solution should also check the reverse (i.e., is the current word the prefix of a previous word?). I did this by using a Trie (which you probably already did) and, after inserting the full word into the Trie (i.e., after reaching the end of the word), checking if the ending node has any children. If yes, the current word is the prefix of a previous word.