why my code with python is wrong?


  • 0
    T
    # code block
    class Solution(object):
        def removeDuplicates(self, nums):
            """
            :type nums: List[int]
            :rtype: int
            """
            if nums == []:
    			return 0
            len_nums = len(nums)
            indexs=[]
            for i in range(len_nums-1):
                for j in range(i+1, len_nums, 1):
                    if nums[i] == nums[j]:
                        indexs.append(j)
            nums = [v for i, v in enumerate(nums) if i not in indexs]
            len_n = len(nums)
            print(nums)
            return len_n
            
    a = [1, 2, 3, 1, 2]        
    s = Solution()
    s.removeDuplicates(a)
    

Log in to reply
 

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