Tap here to switch tabs
Problem
Submissions

Problem: Count Prefix and Suffix Pairs I

med
30 min
Try to solve the Count Prefix and Suffix Pairs I problem.

Statement

You are given a 00 indexed string array words.

Let us define a boolean function isPrefixAndSuffix(str1, str2) that returns true if str1 is both a prefix and a suffix of str2, and false otherwise.

Return the total number of index pairs (i, j) such that i << j and isPrefixAndSuffix(words[i], words[j]) is true.

Constraints:

  • 1≤1 \leq words.length ≤50\leq 50

  • 1≤1 \leq words[i].length ≤10\leq 10

  • words[i] consists only of lowercase English letters.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Prefix and Suffix Pairs I

med
30 min
Try to solve the Count Prefix and Suffix Pairs I problem.

Statement

You are given a 00 indexed string array words.

Let us define a boolean function isPrefixAndSuffix(str1, str2) that returns true if str1 is both a prefix and a suffix of str2, and false otherwise.

Return the total number of index pairs (i, j) such that i << j and isPrefixAndSuffix(words[i], words[j]) is true.

Constraints:

  • 1≤1 \leq words.length ≤50\leq 50

  • 1≤1 \leq words[i].length ≤10\leq 10

  • words[i] consists only of lowercase English letters.