Anyone could figure out why this test case failed?


  • 3
    S

    0_1478756091735_upload-1443832a-567d-4c42-91c3-e7df2c073cd3

    Firstly, I don't know why OJ give back three results in a time. I mean if I got a wrong test case, shouldn't I just get a single test case as feedback?
    Secondly, I think all of these three test cases should NOT return 0, as I can transform hot to dot by "hot"->"dot", and from hot to dog by "hot"->"dot"->"dog".
    So did anyone meet same situation? Please give me some clues, thx


  • 0
    B

    @samparly idk either!!!


  • 0

    @samparly It seems the system returning the wrong feedbacks, sorry about that. There are still lots of improvements we can carry out. @1337c0d3r Don't you think?


  • 0
    S

    same issue for me


  • 0
    S

    I have met the same problem!!!!


  • 0

    The same. I think this test case is wrong.

    "hot", "dot", ["hot","dot","dog"]
    hot -> dot
    2

    "hot", "dog", ["hot","cog","dog","tot","hog","hop","pot","dot"]
    hot -> dot -> dog
    3

    "hot", "dog", ["hot","dog","cog","pot","dot"]
    hot -> dot -> dog
    3

    None of them will be 0.

    I can't figure out why and there might be something wrong with the description of the problem.

    Here is my code.

    class Solution(object):
        def ladderLength(self, beginWord, endWord, wordList):
            """
            :type beginWord: str
            :type endWord: str
            :type wordList: Set[str]
            :rtype: int
            """
            
            # add endWord into list
            wordList.add(endWord)
                
            # create a map of neighbours to wordList:
            d={}
            for word in wordList:
                for i in range(len(word)):
                    key=word[:i]+'_'+word[i+1:]
                    d[key]=d.get(key,[])+[word]
            
            # find neighbours and check if match
            n=1
            cur=[beginWord]
            while d:
                if not cur:
                    return n
                n+=1
                new=[]
                for word in cur:
                    for i in range(len(word)):
                        key=word[:i]+'_'+word[i+1:]
                        if key in d:
                            for target in d[key]:
                                if word!=target:
                                    new.append(target)
                                    if target==endWord:
                                        return n
                            d.pop(key,None)
                cur=new
            return 0

  • 0

    @samparly Perhaps you could post your code for further checking also. Thank you!


  • 0
    S

    @LHearen hi, are you hiring software engineer? I'm looking for internship next summer. ^_^


  • 0
    A

    I'm also having the same problem. Glad I'm not the only one.


  • 0

    @samparly About internship, probably you directly should ask the boss @1337c0d3r. Good luck!


  • 0
    T

    I simply print the input data and got this below, the expect result 0 was right and the feedback input was absolutely wrong.

    hot
    dog
    Set { 'hot', 'dog' }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.