GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — leetcode-1/python/026_Remove_Duplicates_from_Sorted_Array.py at master · GaoSHF/leetcode-1 Expand file tree/ Copy path026_Remove_Duplicates_from_Sorted_Array.pyMore file actions 33 lines (31 loc) · 862 Bytes / Copy path026_Remove_Duplicates_from_Sorted_Array.pyFile metadata and controls33 lines (31 loc) · 862 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 class Solution(object): # def removeDuplicates(self, nums): # """ # :type nums: List[int] # :rtype: int # """ # ls = len(nums) # if ls <= 1: # return ls # last = nums[0] # pos = 1 # for t in nums[1:]: # if t == last: # continue # else: # nums[pos] = t # pos += 1 # last = t # return pos # https://leetcode.com/articles/remove-duplicates-sorted-array/ def removeDuplicates(self, nums): if len(nums) == 0: return 0 left = 0 for i in range(1, len(nums)): if nums[left] == nums[i]: continue else: left += 1 nums[left] = nums[i] return left + 1 |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |