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
Lists vs Dictionaries
00:00
5 left

Lists vs Dictionaries

EasyPython

Problem

What are the differences of list and dictionary?

Asked in the Phone Interview stage, this question focuses on Python data structures. Implement compare_structures(items, mapping) to return a summary containing each structure's type, length, lookup complexity, and the dictionary keys whose values are dictionaries.

Input: items is a Python list, and mapping is a Python dictionary. Output: return a dictionary with keys list_type, dict_type, list_length, dict_length, list_lookup, dict_lookup, and nested_dictionary_keys.

Constraints

  • items is a valid Python list.
  • mapping is a valid Python dictionary.
  • Dictionary keys are hashable.
  • Nested dictionaries are detected only among the top-level dictionary values.
  • Preserve the insertion order of detected nested-dictionary keys.

Function Signature

def compare_structures(items, mapping):
Interviewer

Your question is Lists vs Dictionaries. 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.