Sponsored
Use these hints if you're stuck. Try solving on your own first.
What data structure will allow you to efficiently keep track of the score of each prefix?
Use a Trie. Insert all the words into it, and keep a counter at each node that will tell you how many times we have visited each prefix.