PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Coding & Algorithms/Meta

Compute Max Score From Up to 3 Categories

Last updated: Mar 29, 2026

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.

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
Dec 2, 2025, 12:00 AM
Data Engineer
Technical Screen
Coding & Algorithms
5
0

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:

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:

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).

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Data Engineer•Meta Data Engineer•Meta Coding & Algorithms•Data 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.