0% found this document useful (0 votes)
3 views1 page

Problem Summary

The document outlines a problem to identify the k most frequent elements from a given array of integers. It specifies the input format, which includes an integer array and an integer k, and describes the expected output as a list of the k most frequent elements. Two examples illustrate the problem with their respective inputs and outputs.

Uploaded by

naveenkumar3124
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Problem Summary

The document outlines a problem to identify the k most frequent elements from a given array of integers. It specifies the input format, which includes an integer array and an integer k, and describes the expected output as a list of the k most frequent elements. Two examples illustrate the problem with their respective inputs and outputs.

Uploaded by

naveenkumar3124
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

✅ Problem Summary

Goal: Given a stream (or array) of integers and an integer k, return the k most
frequent elements.

🧾 Input:
●​ An integer array stream (or list of elements).​

●​ An integer k, the number of most frequent elements to track.​

🎯 Output:
●​ A list of the k most frequent elements (order can be arbitrary unless stated otherwise).

✅ Example 1:

Input: nums = [1, 1, 1, 2, 2, 3], k = 2


Output: [1, 2]
// 1 appears 3 times, 2 appears 2 times, 3 appears once

✅ Example 2:
Input: nums = [4, 4, 4, 4, 6, 6, 6, 7, 7, 5], k = 3
Output: [4, 6, 7]
// Frequencies: 4 → 4x, 6 → 3x, 7 → 2x, 5 → 1x

You might also like