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
Map Dictionary Manipulation
00:00
5 left

Map Dictionary Manipulation

HardPython

Problem

Antino Labs mobile configuration is stored as a nested Python dictionary. Implement apply_updates(config, updates) to apply ordered set and delete operations using dot-separated paths.

A set operation must create missing intermediate dictionaries. If an intermediate value is not a dictionary, replace it with an empty dictionary before continuing. A delete operation should do nothing when its path or an intermediate dictionary does not exist. After deletion, remove empty parent dictionaries created by that deletion. The function must not mutate the input config.

Formal Specification

  • config is a dictionary containing JSON-compatible values.
  • updates is a list of dictionaries. Each update has op, which is either "set" or "delete", and path, a non-empty dot-separated string.
  • A set update also contains value, which may be any JSON-compatible value.
  • Return a new dictionary containing the final configuration.
  • Paths always refer to nested dictionary keys and never target the root.

Constraints

  • 1 <= len(updates) <= 10^4
  • 1 <= number of path segments <= 20
  • Keys are non-empty strings without dots
  • Values contain at most 10^4 total nested entries
  • Updates are applied in the given order

Function Signature

def apply_updates(config, updates):
Interviewer

Your question is Map Dictionary Manipulation. 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.