seems correct only but wrong ans
where is the mistake in my code ?
seems correct only but wrong ans
where is the mistake in my code ?
Hey @hg11110000
Like we discussed last time u are pushing multiple copies into it
check this
1
3 2
1 1 1
See the previous discussion Custom comparator class for a priority queue?
Hey @hg11110000
1
3 2
1 1 1
Output for this should be 1 1 1
Again u are doing the same thing pushing multiple copies
@Kartikkhariwal1
i did checked for the number if already present
check the function which i have made
Hey @hg11110000
You haven’t used it for first k insertions
for (i = 0; i < k; ++i)
{
if (m.count(a[i]) == 0)
{
m[a[i]]++;
pq.push({m[a[i]], a[i]});
}
else
{
pair<int, int> x = {m[a[i]], a[i]};
f(pq, x);
m[a[i]]++;
pq.push({m[a[i]], a[i]});
}
pqcopy = pq;
while (!pqcopy.empty())
{
cout << pqcopy.top().second << " ";
pqcopy.pop();
}
}
Use the above
also add endl after testcase
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.