We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Hint: use a data structure like a trie (a prefix tree) since the alphabet is a fixed size.
You should be able to detect during insertion whether the current word is a prefix of a word already in the data structure, or whether there are any other words which have the current word as a prefix.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
No Prefix Set
You are viewing a single comment's thread. Return to all comments →
Hint: use a data structure like a trie (a prefix tree) since the alphabet is a fixed size.
You should be able to detect during insertion whether the current word is a prefix of a word already in the data structure, or whether there are any other words which have the current word as a prefix.