Python: why my IDE output correct while OJ output wrong?


  • 0
    Q

    Here is the code:

    def wordBreak(self, s, dict):
        d = [False] * len(s)
        for w in dict:
            for i in range(len(s)):
                if w==s[i-len(w)+1:i+1] and (d[i-len(w)] or i-len(w)==-1):
                    d[i] = True
        return d[-1]
    

    And the error message:

    Input: "dogs", ["dog","s","gs"]
    Output: false
    Expected: true

    But when I test in my own IDE, it outputs True.
    I just want to know why the answers are different?
    Can anyone help to give me some hints?


  • 0
    J

    I encountered the same issue today. I also do not know what happened to OJ. Do you have any ideas yet?


Log in to reply
 

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