LyWang

removeDuplicate

Nov 25th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. class Solution:
  2.     """
  3.    @param: nums: An ineger array
  4.    @return: An integer
  5.    """
  6.     def removeDuplicates(self, nums):
  7.         # write your code here
  8.         i = 0
  9.         while i < len(nums)-1:
  10.             if nums[i] == nums[i+1]:
  11.                 nums.pop(i)
  12.             else:
  13.                 i+=1
  14.         return len(nums)
Add Comment
Please, Sign In to add comment