PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This Coding & Algorithms question in the Data Engineer domain evaluates grouping and top‑k aggregation concepts, testing the ability to combine per-category aggregation with selection under a uniqueness constraint.

  • hard
  • Meta
  • Coding & Algorithms
  • Data Engineer

Compute Max Score From Up to 3 Categories

Company: Meta

Role: Data Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are implementing a scoring function for a library summer reading program. Each book a student read is represented as a tuple `(category: str, points: int)`. Rules: - The student may count points from **at most 3 books**. - Any counted books must be from **distinct categories** (i.e., you can pick **at most one book per category**). - The student may pick fewer than 3 books if fewer categories exist. Task: Implement the function: ```python from typing import List, Tuple def get_max_score(books: List[Tuple[str, int]]) -> int: """Return the maximum total points achievable under the rules.""" ``` Examples: ```python test1 = [ ("Adventure", 5), ("Adventure", 2), ("History", 3), ] # Pick Adventure(5) + History(3) = 8 assert get_max_score(test1) == 8 test2 = [ ("Adventure", 4), ("History", 3), ("Reference", 1), ("Fiction", 2), ] # Pick top 3 categories: 4 + 3 + 2 = 9 assert get_max_score(test2) == 9 test3 = [ ("Biography", 2), ("Biography", 4), ("Science", 3), ("Science", 1), ] # Pick Biography(4) + Science(3) = 7 assert get_max_score(test3) == 7 test4 = [] assert get_max_score(test4) == 0 ``` Constraints: assume `len(books)` can be large, so your solution should be efficient (better than trying all combinations).

Quick Answer: This Coding & Algorithms question in the Data Engineer domain evaluates grouping and top‑k aggregation concepts, testing the ability to combine per-category aggregation with selection under a uniqueness constraint.

Pick at most one book from each category and at most three books total to maximize points.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([("Adventure",5),("Adventure",2),("History",3)],)

Expected Output: 8

Explanation: Pick the best book per category.

Input: ([("Adventure",4),("History",3),("Reference",1),("Fiction",2)],)

Expected Output: 9

Explanation: Pick the top three categories.

Input: ([("Biography",2),("Biography",4),("Science",3),("Science",1)],)

Expected Output: 7

Explanation: Duplicates within a category reduce to the max.

Input: ([],)

Expected Output: 0

Explanation: No books gives zero.

Hints

  1. Clarify edge cases before coding.
  2. Keep outputs deterministic when several valid answers exist.
Last updated: Jun 27, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ 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
  • 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

  • Find Shortest Unique Prefixes - Meta (medium)
  • Compute Exclusive Execution Times - Meta (medium)
  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)