Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Iterate through all index pairs <code>(i, j)</code>, such that <code>i < j</code>, and check <code>isPrefixAndSuffix(words[i], words[j])</code>.
The answer is the total number of pairs where <code>isPrefixAndSuffix(words[i], words[j]) == true</code>.