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
Deep Equality for Nested Data
00:00
5 left

Deep Equality for Nested Data

EasyPython

Problem

Patreon configuration data can contain nested objects and arrays, such as creator page settings or membership benefit definitions. Implement is_equal(a, b) to determine whether two JSON-like values are structurally and recursively equal.

Formal Specification

The inputs a and b are JSON-like Python values composed only of None, booleans, integers, floats, strings, lists, and dictionaries with string keys. Return True only when:

  1. Both values have the same type and scalar values are equal.
  2. Lists have the same length and equal elements at the same indices.
  3. Dictionaries have the same key set and equal values for every key, regardless of insertion order.

You may assume the structures are acyclic. Do not convert the values to strings or sort serialized output. Implement the comparison directly.

Constraints

  • 0 <= nesting depth <= 100
  • Each structure contains at most 10^4 total values
  • Dictionary keys are strings
  • Inputs are acyclic JSON-like values
  • Lists preserve order, while dictionary insertion order is ignored

Function Signature

def is_equal(a, b):
Interviewer

Your question is Deep Equality for Nested Data. 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.