Tap here to switch tabs
Problem
Submissions

Problem: Count Caesar Cipher Pairs

Try to solve the Count Caesar Cipher Pairs problem.

Statement

You are given an array of strings words.

Two strings of equal length are considered similar if every character in the first string can be shifted cyclically forward in the English alphabet by the same fixed amount to obtain the second string. Shifting the character 'z' forward cyclically wraps around to 'a'.

Return the total number of pairs (i, j) such that 0≤‘i‘<‘j‘<‘words.length‘0 \leq `i` < `j` < `words.length` and words[i] is similar to words[j].

Constraints:

  • 1≤‘n‘==‘words.length‘≤1051 \leq `n` == `words.length` \leq 10^5

  • 1≤‘m‘==‘words[i].length‘≤1051 \leq `m` == `words[i].length` \leq 10^5

  • 1≤‘n‘imes‘m‘≤1051 \leq `n` imes `m` \leq 10^5

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

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Caesar Cipher Pairs

Try to solve the Count Caesar Cipher Pairs problem.

Statement

You are given an array of strings words.

Two strings of equal length are considered similar if every character in the first string can be shifted cyclically forward in the English alphabet by the same fixed amount to obtain the second string. Shifting the character 'z' forward cyclically wraps around to 'a'.

Return the total number of pairs (i, j) such that 0≤‘i‘<‘j‘<‘words.length‘0 \leq `i` < `j` < `words.length` and words[i] is similar to words[j].

Constraints:

  • 1≤‘n‘==‘words.length‘≤1051 \leq `n` == `words.length` \leq 10^5

  • 1≤‘m‘==‘words[i].length‘≤1051 \leq `m` == `words[i].length` \leq 10^5

  • 1≤‘n‘imes‘m‘≤1051 \leq `n` imes `m` \leq 10^5

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