【python】第十六次课作业

本次选取了leetcode上另一道题目41First Missing Positive(原题链接)。

题目如下:


源码如下:

class Solution(object):
    def firstMissingPositive(self, nums):
        if nums != []:
            for i in range(1, 1000):
                if i not in nums:
                    return i
        else:
            return 1
        """
        :type nums: List[int]
        :rtype: int
        """
        

通过后截图如下:


猜你喜欢

转载自blog.csdn.net/karroyzgj/article/details/80111513