更新 Solution.java
parent
7e82ef55c0
commit
8bd3a3b7a3
|
|
@ -175,8 +175,18 @@ public class Solution {
|
||||||
*/
|
*/
|
||||||
public static int removeDuplicates(int[] nums) {
|
public static int removeDuplicates(int[] nums) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int[] newNums = new int[nums.length];
|
for (int j = 0; j < nums.length; j++) {
|
||||||
Map<Integer,Integer> duplicates = new HashMap<>();
|
if (j == 0){
|
||||||
|
nums[i] = nums[j];
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int preValue = nums[j - 1];
|
||||||
|
if (nums[j] != preValue){
|
||||||
|
nums[i] = nums[j];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue