class Solution: ''' @param integer nums @return integer ''' def removeDuplicates(self, nums): i = 0 while i < (len(nums) - 1): if nums[i] is nums[i+1]: del nums[i] else: i += 1 return len(nums)
In local, my code worked. Why got an Output Limit Exceeded Error in OJ? I am so confused! Need some help T_T.
I got the same error too, and got really confused for a while XD
It seems like they don't want you to change the nums array.
If the input is [1,1,2,2,3,3],
they want you to return 3, and modify the nums array to be like [1,2,3,x,x,x]
(whatever 'x' is does not matter), instead of modifying the nums array to be [1,2,3]
This change works out for me, give it a try!