![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
双指针
小马哥MAX
刷题记录BLOG
展开
-
【两次过】Leetcode 27.移除元素
给你一个数组nums和一个值val,你需要原地移除所有数值等于val的元素,并返回移除后数组的新长度。不要使用额外的数组空间,你必须仅使用O(1)额外空间并原地修改输入数组。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。示例 1:输入:nums = [3,2,2,3], val = 3输出:2, nums = [2,2]解释:函数应该返回新的长度 2, 并且 nums 中的前两个元素均为 2。你不需要考虑数组中超出新长度后面的元素。例如,函数返回的新...原创 2021-11-02 09:34:30 · 154 阅读 · 0 评论 -
【一次过】Lintcode 57. 三数之和
给出一个有n个整数的数组S,在S中找到三个整数a, b, c,找到所有使得a + b + c = 0的三元组。样例例1:输入:[2,7,11,15]输出:[]例2:输入:[-1,0,1,2,-1,-4]输出:[[-1, 0, 1],[-1, -1, 2]]注意事项在三元组(a, b, c),要求a <= b <= c。结果不能包含重复的三元组...原创 2019-03-29 10:22:19 · 123 阅读 · 0 评论 -
【简单】Lintcode 100: 删除排序数组中的重复数字
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this in place with con...原创 2018-05-10 11:15:49 · 107 阅读 · 0 评论 -
【简单】Lintcode 101:删除排序数组中的重复数字 II
Follow up for "Remove Duplicates":What if duplicates are allowed at mosttwice?For example,Given sorted array A =[1,1,1,2,2,3],Your function should return length =5, and A is now[1,1,2,2,3].解题思路: ...原创 2018-05-10 11:25:24 · 132 阅读 · 0 评论