Skip to content

Latest commit

 

History

History
47 lines (34 loc) · 1016 Bytes

_1748. Sum of Unique Elements.md

File metadata and controls

47 lines (34 loc) · 1016 Bytes

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 06, 2024

Last updated : July 01, 2024


Related Topics : Array, Hash Table, Counting

Acceptance Rate : 77.87 %


Solutions

C

// Brute forcey based on constraints but eh twas simpler
// Plus consistently 100% runtime with typically good % memory

int sumOfUnique(int* nums, int numsSize) {
    short ref[101] = {0};

    int sum = 0;
    for (int i = 0; i < numsSize; i++) {
        ref[nums[i]]++;
    }

    int output = 0;
    for (int i = 0; i < 101; i++) {
        if (ref[i] == 1) {
            output += i;
        }
    }
    return output;
}