fork download
  1. class Solution(object):
  2. def removeDuplicates(self, nums):
  3. """
  4. :type nums: List[int]
  5. :rtype: int
  6. """
  7. isSecond = False
  8. ele = -1
  9. arr = nums
  10. itemsTobeRemoved = []
  11. for i in arr:
  12. if ele != i:
  13. isSecond = False
  14. ele = i
  15. elif not isSecond:
  16. isSecond = True
  17. else:
  18. itemsTobeRemoved.append(i)
  19. for item in itemsTobeRemoved:
  20. arr.remove(item)
  21. return arr
  22. if __name__ == '__main__':
  23. print Solution().removeDuplicates([1, 1, 1, 2, 3, 3, 3, 4, 4, 4])
Success #stdin #stdout 0.01s 9016KB
stdin
Standard input is empty
stdout
[1, 1, 2, 3, 3, 4, 4]