leetcode 80 Remove Duplicates from Sorted Array II (有序数组去除重复元素)

2017年4月5日 0 作者 CrazyKK

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 being 1, 1, 2, 2 and 3. It doesn’t matter what you leave beyond the new length.

Subscribe to see which companies asked this question.


思路:排序了还不是随便搞? 没要求空间再开一个标记空间。。。O(1)空间的话。。就乱搞一下?