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 = [1,1,2],
Your function should return length = 2, and A is now [1,2].
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 = [1,1,2],
Your function should return length = 2, and A is now [1,2].
本文介绍了一种在不使用额外空间的情况下从已排序数组中去除重复元素的方法,确保每个元素只出现一次,并返回新长度。例如,对于输入数组 [1,1,2],处理后应返回长度为2,且数组变为 [1,2]。
1106

被折叠的 条评论
为什么被折叠?



