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
Explain Existing Codebase and Extend It
00:00
5 left

Explain Existing Codebase and Extend It

HardPython

Problem

Given an existing codebase, explain how it works and its architecture/flow, then implement an additional feature from a problem statement and discuss extensions.

Asked in the live coding / codebase walkthrough stage. For the implementation portion, treat the codebase as a directed module dependency graph and return every module affected by one or more changed modules.

Input and Output

graph maps each module to the modules it directly imports. changed is a list of changed module names. Return all changed modules and their direct or indirect dependents, excluding unknown modules, sorted lexicographically.

Example: graph = {"app": ["auth"], "auth": ["config"], "config": []}, changed = ["config"] returns ["app", "auth", "config"].

Discuss how the design could change for streaming updates, cycles, or very large codebases.

Constraints

  • 1 <= number of modules <= 5000
  • Each module name is a unique non-empty string
  • Every dependency list may contain zero or more module names
  • Unknown dependencies and changed module names are ignored
  • The returned list must be sorted lexicographically

Function Signature

def affected_modules(graph, changed):
Interviewer

Your question is Explain Existing Codebase and Extend It. 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.