Trie | Java | Beginner friendly🔥
class Solution {\n    \n    private class TrieNode{\n        TrieNode[]children;\n        boolean isEnd;\n        int pre_count=0;\n        \n        TrieNode()
class Solution {\n    \n    private class TrieNode{\n        TrieNode[]children;\n        boolean isEnd;\n        int pre_count=0;\n        \n        TrieNode(){\n            children=new TrieNode[26];\n            isEnd=false;\n        }\n    }\n    \n    private TrieNode root;\n    \n    private void insert_word(String s){\n        TrieNode curr=root;\n        \n        for(int i=0;i<s.length();i++){\n            char ch=s.charAt(i);\n            \n            if(curr.children[ch-\'a\']==null){\n                curr.children[ch-\'a\']=new TrieNode();\n            }\n            \n            curr=curr.children[ch-\'a\'];\n            curr.pre_count++;   \n        }\n        \n        curr.isEnd=true;\n    }\n    \n    private int start_word_prefix(String s){\n        \n        TrieNode curr=root;\n        int count=0;\n        \n        for(int i=0;i<s.length();i++){\n            char ch=s.charAt(i);\n            \n            if(curr.children[ch-\'a\']==null)break;\n            \n            curr=curr.children[ch-\'a\'];\n            count+=curr.pre_count;\n        }\n        \n        return count;\n    }\n    \n    public int[] sumPrefixScores(String[] words) {\n        int n=words.length;\n        int i=0;\n        \n        int[]res=new int[n];\n        \n        root=new TrieNode();\n        \n        for(String word:words)insert_word(word);\n        \n        for(String word:words){\n            int count=start_word_prefix(word);\n            res[i++]=count;\n        }\n        \n        return res;\n    }\n}\n\nPlz upvote if you like the solution..
['Trie', 'Java']