public List<Integer> topKFrequent(int[] nums, int k) {
		List<Integer> result = new ArrayList<Integer>();
		
		if (nums == null || nums.length == 0 || k > nums.length || k < 1) {
			return result;
		}
		
		// O(n)
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int n : nums) {
			if (map.keySet().contains(n)) {
				int count = map.get(n);
				map.put(n, count + 1);
			} else {
				map.put(n, 1);
			}
		}
		
		// O(n)
		PriorityQueue<FE> queue = new PriorityQueue<FE>(k, new Comparator<FE>() {
			@Override
			public int compare(FE fe1, FE fe2) {
				return fe1.count - fe2.count;
			}
		});
		
		// O(n)
		for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
			FE fe = new FE(entry.getKey(), entry.getValue());
			queue.offer(fe);
			if (queue.size() > k) {
				queue.poll();
			}
		}
		
		while (!queue.isEmpty()) {
			result.add(queue.poll().value);
		}
		
		Collections.reverse(result);
		
		return result;
	}