Skip to content

Commit cb1e04e

Browse files
authored
Create Count Prefix and Suffix Pairs I.java
1 parent fb2b1ba commit cb1e04e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
public int countPrefixSuffixPairs(String[] words) {
3+
int count = 0;
4+
for (int i = 0; i < words.length; i++) {
5+
String target = words[i];
6+
for (int j = i + 1; j < words.length; j++) {
7+
if (words[j].startsWith(target) && words[j].endsWith(target)) {
8+
count++;
9+
}
10+
}
11+
}
12+
return count;
13+
}
14+
}

0 commit comments

Comments
 (0)