Trie Java Solution.
\nclass Solution {\n\tclass TrieNode {\n        TrieNode[] next;\n        int[] cnt;\n\n        public TrieNode() {\n            next = new TrieNode[26];\n     
```\nclass Solution {\n\tclass TrieNode {\n        TrieNode[] next;\n        int[] cnt;\n\n        public TrieNode() {\n            next = new TrieNode[26];\n            cnt = new int[26];\n        }\n\n        \n    }\n\n    public void insert(String word, TrieNode root) {\n        TrieNode curr = root;\n        for (int i = 0; i < word.length(); i++) {\n            int c = word.charAt(i)-\'a\';\n            if (curr.next[c]==null) {\n                curr.next[c] = new TrieNode();\n                curr.cnt[c] = 1;\n            } else {\n                curr.cnt[c]++;\n            }\n            curr = curr.next[c];\n        }\n    }\n\n    private int getNode(String word, TrieNode root) {\n        TrieNode curr = root;\n        int sum = 0;\n        for (int i = 0; i < word.length(); i++) {\n            int c = word.charAt(i)-\'a\';\n\n            if (curr.next[c]==null) {\n                return 0;\n            }\n            sum+=curr.cnt[c];\n            curr = curr.next[c];\n        }\n        return sum;\n    }\n\n\n    public int[] sumPrefixScores(String[] words) {\n        TrieNode root = new TrieNode();\n        for(String str: words) {\n            insert(str, root);\n        }\n        int n = words.length;\n        int[] ans = new int[n];\n        for(int i=0; i<n; i++) {\n            ans[i] = getNode(words[i], root);\n        }\n        return ans;\n    }\n}\n```
['Depth-First Search', 'Trie']