We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6d3efaf commit ef6181eCopy full SHA for ef6181e
Remove Duplicates from Sorted Array
@@ -0,0 +1,40 @@
1
+class Solution {
2
+ public int removeDuplicates(int[] nums) {
3
+
4
+ if(nums.length==0){
5
+ return 0;
6
+ }
7
+ else if(nums.length == 1){
8
+ return 1;
9
10
+ int i = numberOf(nums);
11
+ removeElements(nums);
12
13
14
15
+ return i;
16
17
18
+ public int[] removeElements(int[] a){
19
+ int j = 1;
20
+ for(int i = 0; i<a.length-1; i++){
21
+ if(a[i] != a[i+1]){
22
+ a[j] = a[i+1];
23
+ j++;
24
25
26
27
+ return a;
28
29
30
+ public int numberOf(int[] a){
31
+ int count = 1;
32
33
34
+ count++;
35
36
37
38
+ return count;
39
40
+}
0 commit comments