---
title: "Discussion on \"Top k frequent elements\" | Hashnode"
description: "Discussion on \"Top k frequent elements\". Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.\nWhen dealing with top k, we would like to think about a priority queue. \nBut first we need to figure out how to keep track of a..."
url: "https://hashnode.com/posts/top-k-frequent-elements/635aa40dc514203d3023953f"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Top k frequent elements](https://simonpyjavaplus.hashnode.dev/top-k-frequent-elements?utm_source=hashnode&utm_medium=feed)

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. When dealing with top k, we would like to think about a priority queue. But first we need to figure out how to keep track of a...

Oct 27, 2022 · 2 min read · simonpyjavaplus.hashnode.dev  
Read the article

-   [#priorityqueue](https://hashnode.com/tag/priorityqueue)
-   [#leetcode](https://hashnode.com/tag/leetcode)
-   [#hashmap](https://hashnode.com/tag/hashmap)

## Written by

[Simon Kuang](https://hashnode.com/@simonpyjavaplus)

@simonpyjavaplus

  
[View profile](https://hashnode.com/@simonpyjavaplus)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
