Compare commits
No commits in common. "8bd3a3b7a374f54be60b093131a44e9b4b9a7eef" and "d38af5164a5ba336907c8fc1573dc0a70e0ab1dc" have entirely different histories.
8bd3a3b7a3
...
d38af5164a
|
|
@ -175,18 +175,8 @@ public class Solution {
|
|||
*/
|
||||
public static int removeDuplicates(int[] nums) {
|
||||
int i = 0;
|
||||
for (int j = 0; j < nums.length; j++) {
|
||||
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;
|
||||
int[] newNums = new int[nums.length];
|
||||
Map<Integer,Integer> duplicates = new HashMap<>();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,11 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class test {
|
||||
public static void main(String[] args) {
|
||||
int[] nums = new int[]{1,2,3,4,4,5,6};
|
||||
Solution.removeDuplicates(nums);
|
||||
int[] nums = new int[]{3,2,2,3,1,2};
|
||||
int[] nums1 = new int[]{1,2,3,0,0,0};
|
||||
int length = Solution.removeElement(nums,3);
|
||||
System.out.println(nums);
|
||||
System.out.println(length);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue