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.
Yes, your solution would work only if the words to be added appear in lexicographical order. The most general way is to add an end-of-word flag for each node and update the count only if it's not set for the last node of the word.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
Yes, your solution would work only if the words to be added appear in lexicographical order. The most general way is to add an end-of-word flag for each node and update the count only if it's not set for the last node of the word.