Can anyone tell why this code got Output Limit Exceeded? Thanks.

  • 0

    Python code.

    class Solution:
    # @return a string
    def convert(self, s, nRows):
        text = []
        if nRows <= 1 or len(s) <= 1:
            return s
        for row in range(nRows):
        for i in range(len(s)):
            current = i % (2*nRows-2)
            if current >= nRows:
                current = 2*nRows-2-current
        result = []
        for row in range(nRows):
            result += text[row]
        return result

Log in to reply

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