#3805

Count Caesar Cipher Pairs

specialist · 865 · lc medium +31 · 50.9% accepted · 105 likes · top 39%

Description

Given an array words of n strings each of length m, two strings are similar if one can be cyclically shifted any number of times (replacing every character with the next in the alphabet, wrapping 'z' back to 'a') to equal the other; return the number of index pairs (i, j) with i < j where words[i] and words[j] are similar.

Code

1
2
3