[LeetCode] Remove Duplicates from Sorted Array (Python)
2024. 2. 27. 11:16ㆍ자료구조
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
if len(nums)==0:
return 0
i=0
for j in range(1,len(nums)):
if nums[i]!=nums[j]:
i+=1
nums[i]=nums[j]
return i+1
'자료구조' 카테고리의 다른 글
[LeetCode] Valid Mountain Array (Python) (0) | 2024.02.29 |
---|---|
[LeetCode] Check If N and Its Double Exist (Python) (0) | 2024.02.29 |
[LeetCode] Remove Element (Python) (0) | 2024.02.27 |
[LeetCode] Merge Sorted Array (Python) (0) | 2024.02.27 |
[LeetCode] Duplicate Zeros (Python) (0) | 2024.02.27 |