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"]
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?