Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc09339f

Browse files
authored
Create 26-Remove-Duplicates-from-Sorted Array
1 parent01a2b36 commitc09339f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution(object):
2+
def removeDuplicates(self, nums):
3+
"""
4+
:type nums: List[int]
5+
:rtype: int
6+
"""
7+
k = 0
8+
i = 0
9+
while i < len(nums):
10+
val = nums[i]
11+
while i + 1 < len(nums) and nums[i+1] == val:
12+
nums.remove(val)
13+
k += 1
14+
i += 1
15+
return len(nums)
16+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp