PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Meta

Find top-K frequent elements in a stream

Last updated: Apr 22, 2026

Quick Overview

This question evaluates understanding of streaming algorithms, frequency estimation, and data-structure-based top-K selection, emphasizing space/time and accuracy trade-offs when processing large or unbounded data.

  • medium
  • Meta
  • Coding & Algorithms
  • Software Engineer

Find top-K frequent elements in a stream

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You receive a large stream of items (e.g., integers or strings) that may not fit in memory. Design an algorithm that can return the top K most frequent items. Requirements: - Provide an exact solution when the number of distinct items fits in memory. - Provide an approximate solution when distinct items are too many (state the error/accuracy tradeoff). Explain time and space complexity for both approaches.

Quick Answer: This question evaluates understanding of streaming algorithms, frequency estimation, and data-structure-based top-K selection, emphasizing space/time and accuracy trade-offs when processing large or unbounded data.

Related Interview Questions

  • Solve Two Backtracking Array Problems - Meta (hard)
  • Solve Array, Matrix, and Recommendation Problems - Meta (medium)
  • Find a String Containing Another - Meta (medium)
  • Solve Subarray Sum and Local Minimum - Meta (hard)
  • Validate abbreviations and brackets - Meta (medium)
Meta logo
Meta
Feb 25, 2026, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
5
0

You receive a large stream of items (e.g., integers or strings) that may not fit in memory. Design an algorithm that can return the top K most frequent items.

Requirements:

  • Provide an exact solution when the number of distinct items fits in memory.
  • Provide an approximate solution when distinct items are too many (state the error/accuracy tradeoff).

Explain time and space complexity for both approaches.

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Software Engineer•Meta Software Engineer•Meta Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.