algorithms.tutorialhorizon.com

Sum of all Unique elements in a given array. | Algorithms

Objective: Given an array of integers which contains duplicates as well. Write a program to find the sum of all unique elements in the array. This problem is also referred as find the sum of all distinct elements in the array Example: [] arrA = {1, 6, 4, 3, 2, 2, 3, 8, 1}; Output : 24 (Unique elements are: 1, 6, 4, 3, 2, 8)