Bug Report for https://neetcode.io/problems/word-ladder
The test cases appear to be missing the case where beginWord == endWord.
According to the problem statement, the answer is the minimum number of words in the transformation sequence needed to obtain endWord. Therefore, when beginWord == endWord, the transformation sequence already contains the single word itself, so the answer should be 1, not 0.
For example:
beginWord = "cat"
endWord = "cat"
wordList = ["cat"]
Expected output:
1
However, returning 0 for beginWord == endWord passes the current test cases.
Could a test case covering this edge case be added?
Bug Report for https://neetcode.io/problems/word-ladder
The test cases appear to be missing the case where beginWord == endWord.
According to the problem statement, the answer is the minimum number of words in the transformation sequence needed to obtain endWord. Therefore, when beginWord == endWord, the transformation sequence already contains the single word itself, so the answer should be 1, not 0.
For example:
beginWord = "cat"
endWord = "cat"
wordList = ["cat"]
Expected output:
1
However, returning 0 for beginWord == endWord passes the current test cases.
Could a test case covering this edge case be added?