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
Recursive Type Extraction
00:00
5 left

Recursive Type Extraction

HardPython

Problem

Globant's frontend teams pass nested configuration objects to design-system components. Implement infer_type_properties(obj) to recursively infer a normalized schema for a JSON-like object.

Return a descriptor with type and, when applicable, additional fields:

  1. Primitive values return {"type": "string"}, {"type": "number"}, {"type": "boolean"}, or {"type": "null"}.
  2. An object returns {"type": "object", "properties": {...}}, where each property maps to its own descriptor.
  3. An array returns {"type": "array", "items": descriptor}. Infer the item descriptor by merging all element descriptors.
  4. An empty array returns {"type": "array", "items": {"type": "unknown"}}.
  5. If values cannot be represented by one descriptor, return {"type": "mixed"}. Arrays containing objects should merge their property keys recursively.
  6. The input itself is always a dictionary. Do not mutate it.

Constraints

  • obj is a dictionary.
  • Values are limited to dictionaries, lists, strings, numbers, booleans, and None.
  • 1 <= total number of input nodes <= 10^5.
  • Dictionary keys are strings.
  • Nesting depth is at most 1,000.
  • Array elements may have different types.

Function Signature

def infer_type_properties(obj):
Interviewer

Your question is Recursive Type Extraction. 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.