What's wrong with my answer?


  • 0
    W

    Here is my solution:

      def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        count = {}
        for i in nums:
          if i in count and count[i] < 2:
            count[i] += 1
          elif i in count and count[i] >= 2:
            continue
          else:
            count[i] = 1
        return sum(count.values())
    

    I tested my code for various cases, it worked locally. But when I submitted OJ, it showed wrong answer. Anything wrong? Thanks!


Log in to reply
 

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