80 Remove Duplicates from Sorted Array II
1. Question
Follow up for "Remove Duplicates": What if duplicates are allowed at mosttwice?
For example,
Given sorted arraynums=[1,1,1,2,2,3]
,
Your function should return length =5
, with the first five elements ofnumsbeing1
,1
,2
,2
and3
. It doesn't matter what you leave beyond the new length.
2. Implementation
3. Time & Space Complexity
时间复杂度O(n), 空间复杂度O(1)
Last updated