第一次做到数组双指针的题目是80: 因为python的List是可以用以下代码来删除元素的: del List[index] 所以当时的我直接用了暴力删除第三个重复元素的做法,大概代码如下: n = len(nums) for i in range(n): if 重复了第i个: del nums[i] i -= 1 在出来7%+5%的提交成功以后,我去看了题解,才发现了可以用双指针做... 在宫水三叶姐的题解中,能使用双指针的本质是利用了「数组有序 & 保留逻辑」两大主要性质.最早接触双指针,还
Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twice and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra mem
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 constant memory. For example,Given input array A = [