Thanks to visit codestin.com Credit goes to github.com
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 7506bf7 commit 7ec157cCopy full SHA for 7ec157c
problems/26.remove-duplicates-from-sorted-array.md
@@ -88,7 +88,7 @@ for (int i = 0; i < len; i++) {
88
89
## 代码
90
91
-- 语言支持:JS,Python,C++
+- 语言支持:JS,Python,C++,Java
92
93
Javascript Code:
94
@@ -149,6 +149,24 @@ public:
149
};
150
```
151
152
+Java Code:
153
+
154
+```java
155
+ public int removeDuplicates(int[] nums) {
156
+ if(nums == null || nums.length == 0) return 0;
157
+ int p = 0;
158
+ int q = 1;
159
+ while(q < nums.length){
160
+ if(nums[p] != nums[q]){
161
+ nums[p + 1] = nums[q];
162
+ p++;
163
+ }
164
+ q++;
165
166
+ return p + 1;
167
+}
168
+```
169
170
**复杂度分析**
171
172
- 时间复杂度:$O(N)$
0 commit comments