Sum of Distinct Element
Vishal Yadav
Posted on January 22, 2022
Solution
#include<bits/stdc++.h>
using namespace std;
void fun(int arr[],int n,int k)
{
}
int main()
{
int arr[42];
int n=42;
for(int i=0;i<n;i++)
cin>>arr[i];
unordered_map<int,int>mp;
for(int i=0;i<n;i++)
{
mp[arr[i]]++;
}
int sum=0;
for(auto it:mp)
{
sum+=it.first;
}
cout<<sum;
return 0;
}
π πͺ π
π©
Vishal Yadav
Posted on January 22, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.