```
class Solution(object):
def removeDuplicates(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
# why the heck LC thinks corner case [] here is meaningful!!!
if nums == []:
return 0
duplicate = 0
max_num = max(nums)
for i in range(len(nums)-1):
if nums[i] == nums[i+1]:
duplicate += 1
nums[i] = max_num
nums.sort()
nums = nums[0:len(nums)-duplicate]
return len(nums)
```