Monday, April 5, 2021

Leetcode Everyday: 1748. Sum of Unique Elements. Easy

public class Solution {
    public int SumOfUnique(int[] nums) {
        var hs = 
            from n in nums
            group n by n into g
            where g.Count() == 1
            select g.Key;
        
        return hs.Sum();
    }
}
Source: https://leetcode.com/problems/sum-of-unique-elements/submissions/