본문 바로가기
카테고리 없음

[LeetCode] Remove Duplicates from Sorted Array 파이썬 (list[:] shallow copy)

by YGSEO 2021. 3. 29.
728x90
class Solution:
    def removeDuplicates(self, nums: List[int]) -> int:
        nums[:] = list(set(nums))
        nums.sort()
        return len(nums)

stackoverflow.com/questions/4081561/what-is-the-difference-between-list-and-list-in-python

 

 

list[:] -> shallow-copies the list

 

비추가 6695에 달하는 문제

728x90

댓글