Python no extra memory used


  • 0
    A
    class Solution(object):
        def removeDuplicates(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            if nums==[]:
                return nums
            uniq=list(set(nums))
            for i in uniq:
                if nums.count(i)>2:
                    while nums.count(i)!=2:
                        nums.remove(i)
            return nums        
    

    Please provide your reviews and suggest in improvising code. Thanks in advance


Log in to reply
 

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