Search⌘ K

Problem Challenge: Suffix Score

Explore how to compute suffix scores for each word in an array by leveraging trie data structures to count matching suffixes. Understand suffix searching and apply this knowledge to solve algorithmic challenges effectively.

Problem statement

Given an array of words of non-empty strings, return an array answer of the same size, where answer[i] is the sum of scores of every non-empty suffix of words[i].

The score of a string word is the number of string words[i] such that the word is a suffix of words[i]. Please note that a string is a suffix of itself.

Example 1

Sample input ...