Skip to content

Commit 6bda381

Browse files
committed
Time: 3 ms (65.21%), Space: 56 MB (9.04%) - LeetHub
1 parent 1c73e49 commit 6bda381

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

3309-count-prefix-and-suffix-pairs-i/3309-count-prefix-and-suffix-pairs-i.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ var countPrefixSuffixPairs = function(words) {
77
const isPrefixAndSuffix = (word1, word2) => {
88
const wordOneLen = word1.length;
99
const wordTwoLen = word2.length;
10-
const isPrefix = () => word1 === word2.slice(0, wordOneLen);
11-
const isSuffix = () => word1 === word2.slice(wordTwoLen-wordOneLen);
12-
if (isPrefix() && isSuffix()) return true;
13-
return false;
10+
const isPrefix = word1 === word2.slice(0, wordOneLen);
11+
const isSuffix = word1 === word2.slice(wordTwoLen-wordOneLen);
12+
return isPrefix && isSuffix;
1413
}
1514
for (let i = 0; i < words.length; i++) {
1615
for (let j = i+1; j < words.length; j++) {

0 commit comments

Comments
 (0)