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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Implementing Unspecified Parsing Logic
00:00
5 left

Implementing Unspecified Parsing Logic

HardPython

Problem

Solve a coding problem where you must implement functions to parse inputs, even when the expected behavior is not fully specified, and explain your approach.

Implement parse_inputs(text) to return a list of records parsed from newline-separated input. Ignore blank lines and lines beginning with #; split fields on commas outside double-quoted values; use the first unquoted = as the key-value separator; trim surrounding whitespace; let later duplicate keys overwrite earlier values; and skip any line containing a malformed field or unterminated quote. Decode escaped double quotes and backslashes inside quoted values.

The input is a string, and the output is a list of maps from strings to strings.

Constraints

  • 0 <= text.length <= 10^5
  • Each record occupies one line
  • Keys and values are strings
  • A malformed field invalidates its entire line
  • Duplicate keys use the last value on the line

Function Signature

def parse_inputs(text):
Interviewer

Your question is Implementing Unspecified Parsing Logic. 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.