Could some Python expert help me explain why my code is MLE, please?

  • 0
    class Solution(object):
        def wordBreak(self, s, wordDict):
            n = len(s)
            d = {}
            for i in xrange(n):
                d[i] = []
                for j in xrange(i+1):
                    word = s[j:i+1]
                    if word in wordDict:
                        if j == 0:
                            for item in [j-1]:
                                d[i].append(item + ' ' + word)
            return d[n-1]

Log in to reply

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