3
int maxEqualFreq(vector<int> &nums) {5
unordered_map<int, int> mp1,6
mp2; // one to store the frequency of each number , and one which will7
// store the frequency of the frequency9
for (int i = 0; i < n; i++) {13
if (i != n - 1 && mp2[mp1[c]] * mp1[c] == i + 1)14
// when curernt length is equal to the total same frequency of numbers15
// then we need one more number which may be anything so doesn't matter16
// . so we just traverse till n-2 and that's it.19
if (mp2[mp1[c]] * mp1[c] == i)20
// when current length is equal to the total same frequency of numbers21
// plus one extra no. ( so here taken ==i (i+1-1)) which can be 1. same22
// as any number present 2. different number .. but doesn't matter and23
// our condition just satisfies ... so just take the current length .