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 }
原文地址:https://www.cnblogs.com/Baronboy/p/10743092.html
时间: 2024-11-08 23:04:03