Comparing every pair of words takes time, where is the number of words and is word length. That is too slow for large inputs.
Instead, for each word, try changing each letter to every letter in the alphabet. For a word like hot, generate *ot, h*t, ho* by masking each position.
Check if these patterns match any word in the word list. Use a hash map from pattern to words. For hot, check if aot, bot,., zot exist, then hat, hbt,., hzt, and so on. This takes per word, much faster than .
Space complexity is for the data structures used.