題目
原題頁面:https://leetcode.com/problems/remove-duplicates-from-sorted-array-ii/
題目型別:Array, Two Pointers
難度評價:Medium
Follow up for "Remove Duplicates":
What if duplicates are allowed at most twice?For example,
Given sorted array nums =[1,1,1,2,2,3],Your function should return length =
5, with the first five elements of nums being1,1,2,2and3. It doesn't matter what you leave beyond the new length.
分析
和Remove Duplicates from Sorted Array類似,只是一個元素可以重複出現最多兩次,因此可以模仿Remove Duplicates from Sorted List II的解法。
程式碼
1 | class Solution: |
本文地址:https://xnerv.wang/zh-tw/leetcode-remove-duplicates-from-sorted-array-ii/
