HTMLify

LeetCode - Sum of Unique Elements - Go
Views: 7 | Author: abh
func sumOfUnique(nums []int) int {
    var sum int = 0;
    for i := 0; i < len(nums); i++ {
        var u bool = true
        for j := 0; j < len(nums); j++ {
            if i == j {
                continue
            } else {
                if nums[i] == nums[j] {
                    u = false
                    break
                }
            }
        }
        if u {
            sum += nums[i]
        }
    }
    return sum
}

Comments