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

Method stringMatching

StringMatchingInAnArray.java:3–20  ·  view source on GitHub ↗
(String[] words)

Source from the content-addressed store, hash-verified

1// build in method
2class Solution {
3 public List<String> stringMatching(String[] words) {
4 List<String> res = new ArrayList<>();
5 int n = words.length;
6 for (int i = 0;i < n;i++) {
7
8 for (int j = 0;j < n;j++) {
9 if (i == j || words[i].length() > words[j].length()) continue;
10
11 if (words[j].contains(words[i])) {
12 res.add(words[i]);
13 break;
14 }
15 }
16
17 }
18
19 return res;
20 }
21}
22
23// custom compare method

Callers

nothing calls this directly

Calls 2

isSubstringMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected