Skip to content

Commit 3ee1ed7

Browse files
Create 0026-Remove-Duplicates-from-Sorted-Array.swift
Swift
1 parent 324cd74 commit 3ee1ed7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
func removeDuplicates(_ nums: inout [Int]) -> Int {
3+
var left: Int = 0
4+
5+
for right in 1..<nums.count {
6+
if nums[right] != nums[left] {
7+
left += 1
8+
nums[left] = nums[right]
9+
}
10+
}
11+
12+
return left + 1
13+
}
14+
}

0 commit comments

Comments
 (0)