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 ee27089 commit 8aa6a46Copy full SHA for 8aa6a46
docs/data-structure/array/README.md
@@ -1016,23 +1016,14 @@ class Solution(object):
1016
1017
```python
1018
# 这个好理解一些
1019
-class Solution(object):
1020
- def removeDuplicates(self, nums):
1021
- """
1022
- :type nums: List[int]
1023
- :rtype: int
1024
1025
- length = len(nums)
1026
-
1027
- if length <= 2:
1028
- return length
1029
+class Solution:
+ def removeDuplicates(self, nums: List[int]) -> int:
1030
i = 0
1031
- for j in range(2, length):
+ for j in range(2, len(nums)):
1032
if nums[i] != nums[j]:
1033
nums[i + 2] = nums[j]
1034
- i = i + 1
1035
+ i += 1
+ # i 指向最后一个被交换的元素
1036
return i + 2
1037
```
1038
0 commit comments