- 博客(3)
- 收藏
- 关注
原创 LeetCode刷题笔记:41MissingPositive
Given an unsorted integer array . Return the smallest positive integer that is not present in .You must implement an algorithm that runs in time and uses auxiliary space.Example 1:Input: nums = [1,2,0]Output: 3Explanation: The numbers in the range [1,2
2024-06-14 22:04:21 815
原创 LeetCode刷题笔记:Leetcode15. 3Sum
题目要求在一个数组中找到所有包含三个不同位置的元素且和为0的组,且要求这些组中不能出现元素相同的组。因此数据结构上明显使用数组,而数组的基本操作有排序和遍历。(做题的时候题干给出的输出让我以为不能对原始数组进行排序,所以没用双指针等办法,直接遍历了。遍历时间复杂度O3太高了,再结合遍历临时数组,直接给干到O6去了,纯纯反例)根据要求取三个变量作为index来遍历整个数组,i、j、k、的大小和顺序保证了在考虑顺序的情况下不会多次记录同一个组。
2024-06-05 20:45:26 784 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人