Skip to content

Bug Report for remove-duplicates-from-sorted-array #4435

@Vulcan46

Description

@Vulcan46

Bug Report for https://neetcode.io/problems/remove-duplicates-from-sorted-array

I have come up with a solution the consistently works in pycharm locally. I can confirm I am using the same versions of python on neetcode as well as pyCharm:

class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        numdict = {}
        for num in nums:
            if num not in numdict:
                numdict[num] = 1
            else:
                numdict[num] += 1
        nums = list(numdict.keys())
        return len(nums)
Image Image Image

My output on leetcode reads: [1,1,2,3], [2,10,10] for case 1 and 2.
Either nums is not getting modified or there is a problem in the dictionary implementation. My solution may not be the most optimal but I feel surely there is a problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions