- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem26.java
More file actions
Latest commit
21 lines (20 loc) · 581 Bytes
/
Copy pathProblem26.java
File metadata and controls
21 lines (20 loc) · 581 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
classProblem26 {
publicstaticvoidmain(String[] args) {
int[] nums = {0, 0, 1, 1, 1, 2, 2, 3, 4};
nums = newint[]{1,2,3};
nums = newint[]{1,2,2,3};
nums = newint[]{1,2,2,2};
intlen = newProblem26().removeDuplicates(nums);
System.out.println(len);
}
publicintremoveDuplicates(int[] nums) {
intcur = 1;
for (inti = 1; i < nums.length; i++) {
if (nums[i] > nums[cur-1]) {
nums[cur] = nums[i];
cur++;
}
}
returncur;
}
}