Leetcode 80]Remove Duplicates from Sorted Array II
来源:互联网 发布:windows系统快捷键设置 编辑:程序博客网 时间:2024/06/04 00:24
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
n=len(nums)
if n<=2:
return n
start=1
for i in range(2,n):
if nums[i]!=nums[start] or nums[i]!=nums[start-1]:
start+=1
nums[i],nums[start]=nums[start],nums[i]
return start+1
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
n=len(nums)
if n<=2:
return n
start=1
for i in range(2,n):
if nums[i]!=nums[start] or nums[i]!=nums[start-1]:
start+=1
nums[i],nums[start]=nums[start],nums[i]
return start+1
0 0
- LeetCode-Array-80 Remove Duplicates from Sorted Array II
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array II
- LeetCode: Remove Duplicates from Sorted Array II
- [Leetcode] Remove Duplicates from Sorted Array II
- [LeetCode] Remove Duplicates from Sorted Array II
- [leetcode] Remove Duplicates from Sorted Array II
- [LeetCode]Remove Duplicates from Sorted Array II
- [leetcode]Remove Duplicates from Sorted Array II
- LeetCode-Remove Duplicates from Sorted Array II
- [leetcode] Remove Duplicates from Sorted Array II
- LeetCode - Remove Duplicates from Sorted Array II
- LeetCode:Remove Duplicates from Sorted Array II
- LeetCode | Remove Duplicates from Sorted Array II
- Leetcode: Remove Duplicates from Sorted Array II
- 【leetcode】Remove Duplicates from Sorted Array II
- Leetcode: Remove Duplicates from Sorted Array II
- [LeetCode] Remove Duplicates from Sorted Array II
- Java_hashCode简介
- jQuery绑定事件的四种方式
- Predix之玩转树莓派(2) 从传感器采集数据
- HDOJ-1016Prime Ring Problem(DFS)
- LeetCode 8. String to Integer (atoi)
- Leetcode 80]Remove Duplicates from Sorted Array II
- 产品经理之web端产品设计-全栈工程师熊盼
- 课堂笔记_ 材质反射属性模型BRDF_01
- git的使用(一)
- Flatten Binary Tree to Linked List
- Linux命令缩写
- 仿腾讯云单选控件
- codeforces Minimum number of steps 思维
- HDU 2639 Bone Collector II (01背包 第K优解)