# Queen's Necklace Editorial RDC1

Author - Yash Dwivedi
Tester - Shubham Kushwaha
Editorialist - Yash Dwivedi

Easy

C++ Stl

# Problem :

Given an array of different types of pearls you need to print Yes if all the types of pearls are present in a unique quantity else print No.

# Quick Explanation

Count the frequency of each a[i] in a map and then insert all those count in a map then if size of map and set are same print Yes else print No

# Explanation

The logic for this Question was simple: you needed to count the number of occurrences for all types of pearls and then put them in a map as well after that check if both have the same size then it would mean that all the pearls are present in a unique quantity.
Count the frequency of each a[i] in a map and then insert all those count in a map then if size of map and set are same print Yes else print No.

# Solution

Setter's Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL)
int t, n;
cin >> t;
while (t–)
{
cin >> n;
int a[n];
map<int, int> mp;
set < int> s;
for(int i=0; i<n; i++)
{
cin >> a[i];
mp[a[i]]++;
}
for (auto i : mp)
{
s.insert(i.second);
}
if (s.size() == m.size())
cout<<“Yes”;
else
cout<<“No”;
cout<<endl;
}
return 0;
}

2 Likes