Leetcode-41.缺失的第一个正数 2025-07-16 Leetcode 225 词 问题的本质是 “存在性查询”,而存在性查询的最优数据结构是哈希表 1234567891011121314151617class Solution: def firstMissingPositive(self, nums: List[int]) -> int: nums.sort() a=set(nums) i=1 while True : if i not in a: return i i+=1 思路很简单:直接把数组排序后,丢到set里面,如果正数的i,不在set里面,说明就是缺少它。 Datawhale-二分类任务 Leetcode-238.除自身以为的数组相乘