educative.io

Which comparator to use?

If this follows Top ‘K’ Elements as mentioned in solution, why do we use a different comparator while creating the Priority Queue ?

Because we are use char and it’s frequency in heap.

frequency is index 0 that why a,b => a[0] - b[0]