class Solution(object):
def removeDuplicates(self, nums):
if not nums:
return 0
if len(nums) == 1:
return 1
i, runner = 0, 1
while runner < len(nums):
if nums[runner] != nums[i]:
i += 1
nums[i] = nums[runner]
runner += 1
return i + 1
Python while using runner O(n) solution

@nirnaor Why the
if len(nums) == 1: return 1
? Doesn't that just slow it down for almost every input, and mislead people into thinking that the rest of your code would fail for inputs of length 1?