Simple Solution Using Trie Data Structure | Java
\n# Code\njava []\nclass Trie {\n    Trie[] arr = new Trie[26];\n    int count = 0;\n}\nclass Solution {\n\n    Trie root = new Trie();\n\n    void add_word(Str
\n# Code\n```java []\nclass Trie {\n    Trie[] arr = new Trie[26];\n    int count = 0;\n}\nclass Solution {\n\n    Trie root = new Trie();\n\n    void add_word(String str) {\n        Trie curr = root;\n        int ind;\n        for(char ch : str.toCharArray()) {\n            ind = ch - \'a\';\n            if(curr.arr[ind] == null) curr.arr[ind] = new Trie();\n            curr = curr.arr[ind];\n            curr.count++;\n        }\n    }\n    int get_value(String str) {\n        Trie curr = root;\n        int ind;\n        int count = 0;\n        for(char ch : str.toCharArray()) {\n            ind = ch - \'a\';\n            if(curr.arr[ind] == null) return count;\n            curr = curr.arr[ind];\n            count += curr.count;\n        }\n        return count;\n    }\n    public int[] sumPrefixScores(String[] words) {\n        for(String str : words) {\n            add_word(str);\n        }\n        int result[] = new int[words.length];\n        int ind = 0;\n        for(String str : words) {\n            result[ind++] = get_value(str);\n        }\n        return result;\n    }\n}\n```
['Java']