题解 | #删除升序数组的重复元素#
删除升序数组的重复元素
https://www.nowcoder.com/practice/fa2ea5ccf0394596b4d7829b17b096ca
import java.util.*; public class Solution { /** * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 * * * @param nums int整型ArrayList * @return int整型 */ public int reArrangeArray (int[] nums) { // write code here if (nums.length==1) { return 1; } int fast = 1; int slow = 1; int previous = nums[0]; int count = 0; while (fast < nums.length) { if (nums[fast]==previous) { count++; }else{ previous = nums[fast]; nums[slow]=previous; slow++; } fast++; } return nums.length - count; } }#这题有问题#