80. 删除有序数组中的重复项 II
生活随笔
收集整理的這篇文章主要介紹了
80. 删除有序数组中的重复项 II
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
80. 刪除有序數組中的重復項 II
Ideas
沒啥技術含量,從后往前,check+delete。
Code
Python
class Solution:def removeDuplicates(self, nums: List[int]) -> int:length = len(nums)for i in range(length - 1, -1, -1):if i > 0 and nums[i] == nums[i - 1]:if i > 1 and nums[i] == nums[i - 2]:del nums[i]return len(nums) 與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的80. 删除有序数组中的重复项 II的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 2015/Province_C_C++_
- 下一篇: 81. 搜索旋转排序数组 II