PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates the ability to perform grouped top-k selection, deterministic tie-breaking and ordering, and to reason about algorithmic efficiency when manipulating structured datasets in the Data Manipulation (SQL/Python) domain for a Data Engineer role.

  • medium
  • Meta
  • Data Manipulation (SQL/Python)
  • Data Engineer

Return top-3 content per category

Company: Meta

Role: Data Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Onsite

Given a collection of items with fields (content_id, category, rating), implement top_k_by_category(items, k= 3) that returns, for each category, the top 3 items by rating. Break ties by higher rating first, then by lexicographically smaller content_id, and keep results sorted by descending rating. Aim for O(n log k) per category using heaps or partial selection.

Quick Answer: This question evaluates the ability to perform grouped top-k selection, deterministic tie-breaking and ordering, and to reason about algorithmic efficiency when manipulating structured datasets in the Data Manipulation (SQL/Python) domain for a Data Engineer role.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding 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.

Related Coding Questions

  • Compare Survey Satisfaction for New and Established Users - Meta (medium)
  • Calculate Daily Survey Response Rates by Country - Meta (medium)
  • Find A Low-Quality Annotator From Label Data - Meta (hard)
  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)