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
Exponential Growth Time to Half
00:00
5 left

Exponential Growth Time to Half

EasyPython

Problem

Handshake is modeling several independent bacteria cultures for a simulation exercise. Each culture doubles in size exactly once every hour and completely fills its container at a specified hour.

Given a list of full-container times, return the corresponding hour when each culture first reaches at least half of its container capacity. A culture that fills at hour h had exactly half the final amount one doubling earlier, at hour h - 1.

Formal Specification

Implement half_fill_times(full_hours), where full_hours is a list of positive integers. Return a list of integers, with each output value representing the first hour at which the corresponding culture reaches half capacity. Assume each culture starts below half capacity and reaches full capacity exactly at its specified hour.

Do not simulate the bacteria hour by hour. The solution should use the doubling relationship directly.

Constraints

  • 1 <= len(full_hours) <= 100,000
  • 1 <= full_hours[i] <= 10^18
  • Each culture doubles exactly once per hour
  • Each culture fills its container exactly at the specified hour

Function Signature

def half_fill_times(full_hours):
Interviewer

Your question is Exponential Growth Time to Half. 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.