[LeetCode/Python] Remove Duplicates from Sorted Array

김미영·2024년 3월 12일

LeetCode

목록 보기
1/11

📌 문제

📝 해결

시간 복잡도 : O(nlogn)

class Solution(object):
    def removeDuplicates(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """
        s = set(nums)#O(n)
        k = len(s) #(2n)

        a = list(s) #(3n)
        h = sorted(a) #(nlogn)
        nums[:] = h #(4n)
        
        return k

0개의 댓글