Python o(n) 56s solution


  • 0
    Y

    """
    class Solution(object):
    def removeDuplicates(self, nums):
    okpoint=1
    if len(nums)<=2:
    return len(nums)
    for i in range(2,len(nums)):
    if nums[i]==nums[okpoint]:
    if nums[i]!=nums[okpoint-1]:
    okpoint+=1
    nums[okpoint]=nums[i]
    else:
    okpoint+=1
    nums[okpoint]=nums[i]
    return okpoint+1
    """


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.