Sum of Prefix Scores of Strings
Hard · Trie · about 25 minutes
Asked at Google, Amazon, Meta.
For an array words, the score of a string t is the number of words that have t as a prefix. For each words[i], return the sum of the scores of all its non-empty prefixes.