Compare commits

..

No commits in common. "8bd3a3b7a374f54be60b093131a44e9b4b9a7eef" and "d38af5164a5ba336907c8fc1573dc0a70e0ab1dc" have entirely different histories.

2 changed files with 7 additions and 15 deletions

View File

@ -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<>();
}
}

View File

@ -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);
}
}