[Leetcode] 26. Remove Duplicates from Sorted Array
[Leetcode] 26. Remove Duplicates from Sorted Array

[Leetcode] 26. Remove Duplicates from Sorted Array

์–ธ์–ด
Python
C
๋‚œ์ด๋„
๋‹ค์‹œ ํ’€์–ด๋ณด๊ธฐ
๋‹ค์‹œ ํ’€์–ด๋ณด๊ธฐ
์•Œ๊ณ ๋ฆฌ์ฆ˜ ์œ ํ˜•
์ž‘์„ฑ์ž
๋ฐ•์šฉ์„ฑ๋ฐ•์šฉ์„ฑ
์ƒ์„ฑ ์ผ์‹œ
2024๋…„ 09์›” 11์ผ
floatFirstTOC: right

๐Ÿ–ฅ๏ธย ์‹œ์ž‘ํ•˜๋ฉฐ

์ด๋ฏธ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ๋˜์–ด์žˆ๊ณ , ์ค‘๋ณต์ธ ๋ถ€๋ถ„์„ ๋ฎ์–ด์”Œ์šฐ๋ฉด ๋˜๋ฏ€๋กœ ๊ฐ„๋‹จํ•˜๊ฒŒ ํ•ด๊ฒฐ๋œ๋‹ค.
ย 

โš™๏ธย Python

from typing import List class Solution: def removeDuplicates(self, nums: List[int]) -> int: if not nums: return 0 uniqueIndex = 1 for i in range(1, len(nums)): if nums[i] != nums[i - 1]: nums[uniqueIndex] = nums[i] uniqueIndex += 1 return uniqueIndex
ย 

๐Ÿ“Œย ์†Œ๊ฐ

๋Œ“๊ธ€

guest