java
int ans=0;\n        HashMap l=new HashMap<>();\n        for(String str:words)\n            l.put(str,l.getOrDefault(str,0)+1);\n        for(int i=0;i<=s.length(
int ans=0;\n        HashMap<String,Integer> l=new HashMap<>();\n        for(String str:words)\n            l.put(str,l.getOrDefault(str,0)+1);\n        for(int i=0;i<=s.length();i++)\n        {\n            String st=s.substring(0,i);\n            if(l.containsKey(st))\n                ans=ans+l.get(st);\n        }\n        return ans;
['Java']