更新 Solution.java
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user