i慢指针,j快指针。由于原排列已经排序,所以i从0开始,j从1开始,如果i的值等于j的值,则j后移一位。如果i不等于j的值,则i后移一位,并且用nuns[i]记录此时nums[j]的值。然后j继续后移。
//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 ...
Some results have been hidden because they may be inaccessible to you
Show inaccessible results