words, all of the same length. Check whether two of them differ in exactly one position, with the same letter in every other place.
Return True if such a pair exists and False otherwise.
Trying every pair is the obvious way; aim for O(n · m), where n is the number of words and m is their length.words=['lamp', 'ramp', 'rump', 'dump'] → True
"lamp" and "ramp" differ only in the first letter, so such a pair exists.
words=['abc', 'bca', 'cab'] → False
Any two of the words differ in all three positions, so there is no pair.
words=['x'] → False
There is only one word, nothing to compare it with.
words=['lamp', 'ramp', 'rump', 'dump']
True
Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.