(String[] words)
| 1 | class Solution { |
| 2 | public int[] sumPrefixScores(String[] words) { |
| 3 | HashMap<String,Integer> map =new HashMap<>(); |
| 4 | int count[] = new int[words.length]; //res |
| 5 | for(String word : words){ |
| 6 | StringBuilder sb = new StringBuilder(); |
| 7 | for(int i=0;i<word.length();i++){ |
| 8 | sb.append(word.charAt(i)); |
| 9 | String w = sb.toString(); |
| 10 | map.put(w,map.getOrDefault(w,0)+1); |
| 11 | } |
| 12 | } |
| 13 | int index=0; |
| 14 | for(String word : words){ |
| 15 | int c=0; |
| 16 | StringBuilder sb = new StringBuilder(); |
| 17 | for(int i=0;i<word.length();i++){ |
| 18 | sb.append(word.charAt(i)); |
| 19 | String w = sb.toString(); |
| 20 | c += map.get(w); |
| 21 | } |
| 22 | count[index] = c; |
| 23 | index++; |
| 24 | } |
| 25 | return count; |
| 26 | } |
| 27 | } |
| 28 | |
| 29 |
nothing calls this directly
no outgoing calls
no test coverage detected