---
title: "Discussion on \"Top K Frequent Elements — When HashMaps Start Earning Their Salary\" | Hashnode"
description: "Discussion on \"Top K Frequent Elements — When HashMaps Start Earning Their Salary\". Given an integer array nums and an integer k, return the k most frequent elements within the array.\nThe test cases are generated such that the answer is always unique.\nExample 1:\nInput: nums = [1,2,2,"
url: "https://hashnode.com/posts/top-k-frequent-elements-when-hashmaps-start-earning-their-salary/69a08beb7c75fd531024c35c"
---

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

Discussion

# [Top K Frequent Elements — When HashMaps Start Earning Their Salary](https://kaushalm.hashnode.dev/top-k-frequent-elements-when-hashmaps-start-earning-their-salary?utm_source=hashnode&utm_medium=feed)

Given an integer array nums and an integer k, return the k most frequent elements within the array. The test cases are generated such that the answer is always unique. Example 1: Input: nums = \[1,2,2,

Feb 26 · 2 min read · kaushalm.hashnode.dev  
Read the article

-   [#dsa](https://hashnode.com/tag/dsa)

## Written by

[Kaushal Maurya](https://hashnode.com/@KaushalM)

@KaushalM

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

Building the future, one line of code at a time.

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
