What is the running time? Why is it accepted?


  • 0
    X
    class Solution:
        # @param A, a list of integers
        # @return an integer
        def firstMissingPositive(self, A):
            count = 0
            result  = 1
            num = 0
            A.append(0)
            while self.ifzero(A) == True:
                for count in range(0,len(A)):
                    A[count] = A[count] - 1
                num = num + 1
                if self.ifzero(A) == False:
                    return num
                    break
        def ifzero(self,B):
            count = 0
            result = 1
            for count in range(0,len(B)):
                 result = result * B[count]
                 if result == 0:
                    return True
                    break
            return False

Log in to reply
 

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