Ezvor

1554. Strings Differ by One Character

MediumHash Table Preparing judge… LeetCode
Hash TableStringRolling HashHash Function

Hints

Hint 1
BruteForce, check all pairs and verify if they differ in one character. O(n^2 * m) where n is the number of words and m is the length of each string.
Hint 2
O(m^2 * n), Use hashset, to insert all possible combinations adding a character "*". For example: If dict[i] = "abc", insert ("*bc", "a*c" and "ab*").