TCS OA-4 2024
Problem Description
You are given an integer array nums. The unique elements of an array are the elements that appear exactly once in the array.
Return the sum of all the unique elements of nums.
Input Format
- The first line contains an integer N, representing the length of the array.
- The second line contains N space-separated integers.
Output Format
Print the sum of all the unique elements of nums.
Constraints
- 1 ≤ N ≤ 10⁵
- -10⁵ ≤ nums[i] ≤ 10⁵
Example
Sample Input:
7
[1,5,3,4,1,3,2]
Sample Output:
11
Explanation:
The unique elements are: 5, 4, 2
Therefore, 5+4+2 = 11.