Given a sorted array nums, 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 by modifying the input array in-place with O(1) extra memory.
Example 1:
Given nums = [1,1,2], Your function should return length =2, with the first two elements ofnumsbeing1and2respectively. It doesn't matter what you leave beyond the returned length.

本文介绍了一个算法问题:如何在不使用额外空间的情况下,对已排序的数组进行原地修改,以确保每个元素只出现一次,并返回新的有效长度。示例中,对于数组[1,1,2],经过处理后,应返回长度为2,且数组的前两个元素分别为1和2。
1089

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



