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 31c410b commit 6ec759eCopy full SHA for 6ec759e
solution/0026.Remove Duplicates from Sorted Array/Solution.go
@@ -0,0 +1,21 @@
1
+/**
2
+ * @lc app=leetcode.cn id=26 lang=golang
3
+ * Accepted
4
+ * 161/161 cases passed (144 ms)
5
+ * Your runtime beats 36.91 % of golang submissions
6
+ * Your memory usage beats 40.4 % of golang submissions (8.2 MB)
7
+ */
8
+
9
+func removeDuplicates(nums []int) int {
10
+ if nums == nil || len(nums) == 0 {
11
+ return 0
12
+ }
13
+ j := 0
14
+ for i := 1; i < len(nums); i++ {
15
+ if nums[j] != nums[i] {
16
+ j++
17
+ nums[j] = nums[i]
18
19
20
+ return j + 1
21
+}
0 commit comments