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

Method isSubstring

StringMatchingInAnArray.java:45–65  ·  view source on GitHub ↗
(String sub, String word)

Source from the content-addressed store, hash-verified

43
44
45 public boolean isSubstring(String sub, String word) {
46 int n = word.length();
47 int m = sub.length();
48 for (int j = 0; j< n; j++) {
49 boolean isMatch = true;
50 int k=j;
51 int i=0;
52 while(i<m){
53 if (k >= word.length() || word.charAt(k) != sub.charAt(i)) {
54 isMatch = false;
55 break;
56 }
57 k++;
58 i++;
59 }
60 if (isMatch) {
61 return true;
62 }
63 }
64 return false;
65 }
66}

Callers 1

stringMatchingMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected