Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Max Points With Category Constraints
00:00
5 left

Max Points With Category Constraints

EasyPython

Problem

Meta AI is evaluating a reading list where each book has a category and a recommendation-point value. Given a dictionary of books, choose exactly three books whose categories are all different and return the maximum total points.

Formal Specification

Implement max_points_three_categories(books). The input books is a dictionary mapping a unique book ID to a dictionary with two fields: category, a string, and points, an integer. The function must return an integer representing the greatest possible sum of points from three books with pairwise-distinct categories. You may not select the same book more than once.

The input always contains at least three distinct categories, so a valid selection exists. The result depends only on the highest-point book in each category.

Constraints

  • 3 <= len(books) <= 10^6
  • Each book ID is unique
  • Each category is a non-empty string
  • -10^9 <= points <= 10^9
  • At least three distinct categories exist

Function Signature

def max_points_three_categories(books):
Interviewer

Your question is Max Points With Category Constraints. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.