MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

countingWordsWithAGivenString.java:1–15  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2 public int prefixCount(String[] words, String pref) {
3 int count=0;
4 int len = pref.length();
5 for(String word : words){
6 if(len <= word.length()){
7 String sub = word.substring(0,len);
8 if(pref.equals(sub)){
9 count++;
10 }
11 }
12 }
13 return count;
14 }
15}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected