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
Refactor a Failing Notebook Integration
00:00
5 left

Refactor a Failing Notebook Integration

MediumPython

Problem

Given a Jupyter notebook with a failing model integration, identify the bottleneck and propose a refactor.

Assume the notebook executes a sequence of cells represented as Python callables. Each cell may load data, preprocess it, or call the model integration. Return the index of the cell that is the bottleneck, defined as the cell with the highest repeated execution cost across a full notebook run, and describe the refactor that removes the repeated work.

Input

A list of notebook cells, where each cell is a dictionary with fields name, cost, and repeated. cost is the execution cost of one run, and repeated is a boolean indicating whether the cell is executed more than once due to notebook structure.

Output

Return a tuple (bottleneck_index, refactor_name).

Constraints

  • 1 <= len(cells) <= 10^4
  • 0 <= cost <= 10^9
  • Each cell has keys: name, cost, repeated
  • Exactly one bottleneck cell exists among repeated cells

Function Signature

def diagnose_bottleneck(cells):
Interviewer

Your question is Refactor a Failing Notebook Integration. 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.