LINUX.ORG.RU

История изменений

Исправление qulinxao3, (текущая версия) :

omem(1)?

class Solution:
    def firstMissingPositive(self, n: List[int]) -> int:
        l=len(n)
        n=set(i for i in set(n) if i<=l and i>0)
        if not n: return 1
        for i in range(1,max(n)+2):
            if i not in n:return i

Исходная версия qulinxao3, :

o(1)?

class Solution:
    def firstMissingPositive(self, n: List[int]) -> int:
        l=len(n)
        n=set(i for i in set(n) if i<=l and i>0)
        if not n: return 1
        for i in range(1,max(n)+2):
            if i not in n:return i