难度: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 being 1, 1, 2, 2 and 3.
It doesn't matter what you leave beyond the new length.
此类题肯定是要用到hashtable,key对应的value是该数字出现的次数,当出现的次数超过两次,(注意顺序)先将value降至2,再删除原list中的element,最后修改while语句中的n。