Why the performance varies so much 160ms-330ms?

  • 0
        def setZeroes(self, matrix):
            row = len(matrix)
            column = len(matrix[0])
            columns = set()
            for i in xrange(row):
                found = False
                for j in xrange(column):
                    if matrix[i][j] == 0:
                        found = True
                if found:
                    for j in range(column):
                        matrix[i][j] = 0
            for i in xrange(column):
                if i in columns:
                    for j in xrange(row):
                        matrix[j][i] = 0

Log in to reply

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