4
Node(int data, int freq, int time) {11
class CompareNode implements Comparator<Node> {13
public int compare(Node a, Node b) {14
if (a.freq - b.freq == 0) {15
return b.time - a.time;17
return b.freq - a.freq;22
PriorityQueue<Node> pq;23
Map<Integer, Node> map;27
pq = new PriorityQueue<>(new CompareNode());28
map = new HashMap<>();31
public void push(int val) {34
if (map.containsKey(val)) {35
freq += map.get(val).freq;37
map.put(val, new Node(val, freq, c));38
pq.add(new Node(val, freq, c++));43
Node a = map.get(r.data);