Java || Trie Solution
\nclass Solution {\n    public int[] sumPrefixScores(String[] words) {\n        \n        Tries trie=new Tries();\n        \n        \n        \n        for(Str
```\nclass Solution {\n    public int[] sumPrefixScores(String[] words) {\n        \n        Tries trie=new Tries();\n        \n        \n        \n        for(String word:words){\n            \n            add(word,trie);\n        }\n        \n        int[] res=new int[words.length];\n        \n        \n        for(int i=0;i<words.length;i++){\n            \n            Tries temp=trie;\n            res[i]=count(temp,words[i],0);\n        }\n        return res;\n    }\n    \n    public int count(Tries temp,String word,int in){\n        \n        \n        if(in==word.length()) return 0;\n        char ch=word.charAt(in);\n        \n        int ans=0;\n        if(temp.map.containsKey(ch)){\n           // System.out.println(ch+" -->"+temp.count);\n          ans+=temp.map.get(ch).count+count(temp.map.get(ch),word,in+1);  \n            \n        }\n        return ans;\n    }\n    \n    public void add(String str,Tries trie){\n        \n        Tries temp=trie;\n        for(int i=0;i<str.length();i++){\n            \n            char ch=str.charAt(i);\n            \n            if(!temp.map.containsKey(ch)){\n                temp.map.put(ch,new Tries());\n            }\n            \n            \n            temp=temp.map.get(ch);\n            temp.count+=1;\n        }\n    }\n    public class Tries{\n        \n        HashMap<Character,Tries> map=new HashMap<>();\n        int count=0;\n    }\n}\n```
['Trie', 'Java']