PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Meta

Compute maximum score using up to 3 categories

Last updated: Mar 29, 2026

Quick Overview

This question evaluates skills in grouping and aggregation of items and constrained selection to maximize a numeric objective, reflecting competency in data manipulation and combinatorial optimization.

  • easy
  • Meta
  • Coding & Algorithms
  • Data Scientist

Compute maximum score using up to 3 categories

Company: Meta

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

## Problem A library runs a summer reading program. Each book a student reads earns a certain number of points, and each book belongs to a **category**. A student may score points from **at most 3 books**, with the restriction that the selected books must be from **distinct categories** (i.e., no two selected books can share the same category). Given a list of books the student read, compute the **maximum total score** the student can achieve. ### Input - `books`: a list of tuples `(category: str, points: int)` - The list may be empty. - Assume `points` are integers (typically non-negative). ### Output - Return an integer: the maximum achievable total points. ### Function signature (Python) ```python def get_max_score(books: list[tuple[str, int]]) -> int: ... ``` ### Examples / Tests ```python test1 = [ ("Adventure", 5), ("Adventure", 2), ("History", 3), ] assert get_max_score(test1) == 8 # 5 (Adventure) + 3 (History) test2 = [ ("Adventure", 4), ("History", 3), ("Reference", 1), ("Fiction", 2), ] assert get_max_score(test2) == 9 # 4 + 3 + 2 test3 = [ ("Biography", 2), ("Biography", 4), ("Science", 3), ("Science", 1), ] assert get_max_score(test3) == 7 # 4 + 3 test4 = [] assert get_max_score(test4) == 0 ``` ### Clarifications - You may pick 0, 1, 2, or 3 books (whichever maximizes the score). - You cannot pick more than one book from the same category.

Quick Answer: This question evaluates skills in grouping and aggregation of items and constrained selection to maximize a numeric objective, reflecting competency in data manipulation and combinatorial optimization.

Related Interview Questions

  • Solve Tree Columns And Maze Variants - Meta (medium)
  • Solve Tree Diameter and Palindromic Counts - Meta (medium)
  • Simulate Monster Team Battles - Meta (hard)
  • Solve a Key-Door Corridor Maze - Meta (medium)
  • Solve Array Merge and Parentheses Cleanup - Meta (medium)
Meta logo
Meta
Dec 2, 2025, 12:00 AM
Data Scientist
Technical Screen
Coding & Algorithms
4
0

Problem

A library runs a summer reading program. Each book a student reads earns a certain number of points, and each book belongs to a category.

A student may score points from at most 3 books, with the restriction that the selected books must be from distinct categories (i.e., no two selected books can share the same category).

Given a list of books the student read, compute the maximum total score the student can achieve.

Input

  • books : a list of tuples (category: str, points: int)
    • The list may be empty.
    • Assume points are integers (typically non-negative).

Output

  • Return an integer: the maximum achievable total points.

Function signature (Python)

def get_max_score(books: list[tuple[str, int]]) -> int:
    ...

Examples / Tests

test1 = [
    ("Adventure", 5),
    ("Adventure", 2),
    ("History", 3),
]
assert get_max_score(test1) == 8  # 5 (Adventure) + 3 (History)

test2 = [
    ("Adventure", 4),
    ("History", 3),
    ("Reference", 1),
    ("Fiction", 2),
]
assert get_max_score(test2) == 9  # 4 + 3 + 2

test3 = [
    ("Biography", 2),
    ("Biography", 4),
    ("Science", 3),
    ("Science", 1),
]
assert get_max_score(test3) == 7  # 4 + 3

test4 = []
assert get_max_score(test4) == 0

Clarifications

  • You may pick 0, 1, 2, or 3 books (whichever maximizes the score).
  • You cannot pick more than one book from the same category.

Submit Your Answer

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Meta•More Data Scientist•Meta Data Scientist•Meta Coding & Algorithms•Data Scientist Coding & Algorithms
PracHub

Master your tech interviews with 8,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.