删除数组重复项
作者:互联网
1 class Solution { 2 public int removeDuplicates(int[] nums) { 3 int length = nums.length - 1; 4 for (int i = 0; i <= length; i++) { 5 for (int j = i + 1; j <= length; j++) { 6 if (nums[i] == nums[j]) { 7 for (int k = i; k <length ; k++) { 8 nums[k] = nums[k + 1]; 9 } 10 nums[length] = 0; 11 length--; 12 j--; 13 } 14 } 15 } 16 length++; 17 return length; 18 19 } 20 }
标签:删除,nums,重复,Solution,int,length,数组,removeDuplicates,class 来源: https://www.cnblogs.com/Baronboy/p/10743092.html