public List<Integer> topKFrequent(int[] nums, int k) {
        Map<Integer,Integer> aux=new HashMap<>();
        for(int i : nums){
            Integer cnt=0;
            if(aux.containsKey(i)) cnt=aux.get(i);
            aux.put(i,++cnt);
        }
        PriorityQueue<Node> priorityQueue=new PriorityQueue<>();
        for(Map.Entry<Integer,Integer> entry : aux.entrySet()){
            priorityQueue.add(new Node(entry.getKey(),entry.getValue()));
            if(priorityQueue.size()>k) priorityQueue.poll();
        }
        List<Integer> result=new ArrayList<>();
        for(Node n : priorityQueue) result.add(n.i);
        return result;
    }