leetcode——41. 缺失的第一个正数
作者:互联网
class Solution(object): def firstMissingPositive(self, nums): """ :type nums: List[int] :rtype: int """ if nums==[]: return 1 for i in nums: if i<=0: nums.remove(i) if nums==[]: return 1 for i in range(1,len(nums)+1): if i not in nums: return i return len(nums)+1执行用时 :24 ms, 在所有 python 提交中击败了90.19%的用户 内存消耗 :11.8 MB, 在所有 python 提交中击败了26.09%的用户 ——2019.10.14
标签:击败,nums,int,用户,41,python,提交,正数,leetcode 来源: https://www.cnblogs.com/taoyuxin/p/11670778.html