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
Compute Courier Acceptance Rate
00:00
5 left

Compute Courier Acceptance Rate

EasyPython

Problem

You are given an array of objects where each object contains a courier reaction to a new order from a restaurant. Calculate the acceptance rate for orders for each courier.

Each object has courier_id and reaction, where reaction is either "accepted" or "rejected". Implement def acceptance_rates(reactions): and return a dictionary mapping each courier ID to a decimal acceptance rate, calculated as accepted reactions divided by total reactions.

Constraints

  • 0 <= reactions.length <= 10^5
  • Each reaction contains a non-empty courier_id string
  • reaction is either "accepted" or "rejected"
  • A courier appears in at least one reaction
  • Return rates as decimal values from 0.0 through 1.0

Function Signature

def acceptance_rates(reactions):
Interviewer

Your question is Compute Courier Acceptance Rate. 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.