Skip to content

Commit 88c010e

Browse files
authored
Update Solution to 026[python2] - 48ms
1 parent 33fd3fa commit 88c010e

File tree

1 file changed

+14
-0
lines changed
  • solution/026.Remove Duplicates from Sorted Array

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+
#48ms
2+
class Solution(object):
3+
def removeDuplicates(self, nums):
4+
if not nums:
5+
return 0
6+
7+
newtail = 0
8+
9+
for i in range(1, len(nums)):
10+
if nums[i] != nums[newtail]:
11+
newtail += 1
12+
nums[newtail] = nums[i] #只要求字符串前段正确即可
13+
14+
return newtail + 1 #要求返回新字符串长度

0 commit comments

Comments
 (0)