본문 바로가기

IT/코딩테스트

[Leetcode] 1748. Sum of Unique Elements

728x90

https://leetcode.com/problems/sum-of-unique-elements

class Solution:
    def sumOfUnique(self, nums: List[int]) -> int:
        
        unique = []
        for i in nums[:]:
            if nums.count(i) == 1:
                unique.append(i)

        sum = 0
        for i in unique:
            sum += i

        return sum
728x90