728x90
https://leetcode.com/problems/remove-duplicates-from-sorted-array/
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
count = len(nums)
before = nums[0]
for i in range(1, len(nums)):
if before == nums[i]:
nums[i] = 101
count -= 1
else:
before = nums[i]
nums.sort()
return count
728x90
'IT > 코딩테스트' 카테고리의 다른 글
[Leetcode] 905. Sort Array By Parity (0) | 2023.08.26 |
---|---|
[Leetcode] 620. Not Boring Movies (0) | 2023.08.25 |
[Leetcode] 1068. Product Sales Analysis I (0) | 2023.08.24 |
[Leetcode] 283. Move Zeroes (0) | 2023.08.23 |
[Leetcode] 1378. Replace Employee ID With The Unique Identifier (0) | 2023.08.23 |